2021-05-15 16:47:15 +03:00
|
|
|
{ system ? builtins.currentSystem }:
|
|
|
|
let
|
|
|
|
# nixpkgs / devshell is only used for development. Don't add it to the flake.lock.
|
2024-07-03 00:15:39 +03:00
|
|
|
nixpkgsGitRev = "4670114d91b4631a673cac508185b47b394f6fd8";
|
|
|
|
devshellGitRev = "1ebbe68d57457c8cae98145410b164b5477761f4";
|
2021-05-15 16:47:15 +03:00
|
|
|
|
|
|
|
nixpkgsSrc = fetchTarball {
|
|
|
|
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsGitRev}.tar.gz";
|
2024-07-03 00:15:39 +03:00
|
|
|
sha256 = "1pxm0kr5rlq8565kncsnnghqck9s5xi8zd2va8jkpd66s60ai3z1";
|
2021-05-15 16:47:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
devshellSrc = fetchTarball {
|
|
|
|
url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz";
|
2024-07-03 00:15:39 +03:00
|
|
|
sha256 = "0mm1kallhn9zvprnb1b1ln204iadwgd4bkqkdmdzdrdplwb88hs3";
|
2021-05-15 16:47:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
pkgs = import nixpkgsSrc { inherit system; };
|
2022-03-14 15:03:40 +03:00
|
|
|
devshell = import devshellSrc { inherit system; };
|
2021-05-15 16:47:15 +03:00
|
|
|
|
|
|
|
withCategory = category: attrset: attrset // { inherit category; };
|
|
|
|
util = withCategory "utils";
|
|
|
|
|
2021-12-13 11:33:54 +03:00
|
|
|
rootDir = "$PRJ_ROOT";
|
|
|
|
|
2021-05-15 16:47:15 +03:00
|
|
|
test = name: withCategory "tests" {
|
|
|
|
name = "check-${name}";
|
|
|
|
help = "Checks ${name} testcases";
|
|
|
|
command = ''
|
|
|
|
set -e
|
2021-07-18 22:29:14 +03:00
|
|
|
echo -e "\n\n##### Building ${name}\n"
|
2021-12-13 11:33:54 +03:00
|
|
|
cd ${rootDir}/tests/${name}
|
|
|
|
nix flake show --allow-import-from-derivation --no-write-lock-file "$@"
|
2021-07-18 22:29:14 +03:00
|
|
|
nix flake check --no-write-lock-file "$@"
|
2021-05-15 16:47:15 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dry-nixos-build = example: host: withCategory "dry-build" {
|
|
|
|
name = "build-${example}-${host}";
|
|
|
|
command = ''
|
|
|
|
set -e
|
2021-07-18 22:29:14 +03:00
|
|
|
echo -e "\n\n##### Building ${example}-${host}\n"
|
2021-12-13 11:33:54 +03:00
|
|
|
cd ${rootDir}/examples/${example}
|
2021-07-18 22:29:14 +03:00
|
|
|
nix flake show --no-write-lock-file "$@"
|
2021-07-18 22:33:25 +03:00
|
|
|
nix build .#nixosConfigurations.${host}.config.system.build.toplevel --no-write-lock-file --no-link "$@"
|
2021-05-15 16:47:15 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
devshell.mkShell {
|
|
|
|
name = "flake-utils-plus";
|
|
|
|
packages = with pkgs; [
|
|
|
|
fd
|
|
|
|
nixpkgs-fmt
|
|
|
|
];
|
|
|
|
|
|
|
|
commands = [
|
|
|
|
{
|
2021-12-13 11:33:54 +03:00
|
|
|
command = "git rm --ignore-unmatch -f ${rootDir}/{tests,examples}/*/flake.lock";
|
2021-05-15 16:47:15 +03:00
|
|
|
help = "Remove all lock files";
|
|
|
|
name = "rm-locks";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "fmt";
|
|
|
|
help = "Check Nix formatting";
|
2021-12-13 11:33:54 +03:00
|
|
|
command = "nixpkgs-fmt \${@} ${rootDir}";
|
2021-05-15 16:47:15 +03:00
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "evalnix";
|
|
|
|
help = "Check Nix parsing";
|
|
|
|
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null";
|
|
|
|
}
|
2022-03-14 15:03:40 +03:00
|
|
|
{
|
|
|
|
category = "dry-build";
|
|
|
|
name = "build-darwin";
|
|
|
|
command = "nix build ${rootDir}/examples/darwin#darwinConfigurations.Hostname1.system --no-write-lock-file --dry-run";
|
|
|
|
}
|
2021-05-15 16:47:15 +03:00
|
|
|
|
2024-07-03 00:15:39 +03:00
|
|
|
#(test "channel-patching")
|
2021-05-15 16:47:15 +03:00
|
|
|
(test "derivation-outputs")
|
|
|
|
(test "hosts-config")
|
|
|
|
(test "overlays-flow")
|
2024-07-03 00:15:39 +03:00
|
|
|
(test "all" // { command = "check-derivation-outputs && check-hosts-config && check-overlays-flow"; })
|
2021-05-19 12:15:21 +03:00
|
|
|
|
2021-05-15 16:47:15 +03:00
|
|
|
(dry-nixos-build "minimal-multichannel" "Hostname1")
|
|
|
|
(dry-nixos-build "minimal-multichannel" "Hostname2")
|
2024-07-03 00:15:39 +03:00
|
|
|
#(dry-nixos-build "home-manager+nur+neovim" "Rick")
|
2021-05-15 16:47:15 +03:00
|
|
|
(dry-nixos-build "exporters" "Morty")
|
2024-07-03 00:15:39 +03:00
|
|
|
(withCategory "dry-build" { name = "build-all"; command = "build-exporters-Morty && build-minimal-multichannel-Hostname1 && build-minimal-multichannel-Hostname2"; })
|
2021-05-19 12:15:21 +03:00
|
|
|
|
2021-05-15 16:47:15 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
}
|