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.
|
2023-10-02 23:06:48 +03:00
|
|
|
nixpkgsGitRev = "15de3b878a1fab784ddeae4c33cbc56381748505";
|
|
|
|
devshellGitRev = "cd4e2fda3150dd2f689caeac07b7f47df5197c31";
|
2021-05-15 16:47:15 +03:00
|
|
|
|
|
|
|
nixpkgsSrc = fetchTarball {
|
|
|
|
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsGitRev}.tar.gz";
|
2023-10-02 23:06:48 +03:00
|
|
|
sha256 = "1nb53mycxj3hqcxg1vwbz76rkbmzkp84jgljqv6q2rby5v9k8cwc";
|
2021-05-15 16:47:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
devshellSrc = fetchTarball {
|
|
|
|
url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz";
|
2023-10-02 23:06:48 +03:00
|
|
|
sha256 = "02h3j2wqxsgf8sfl476q070ss86palxba48i497kh69nrvhqgz84";
|
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
|
|
|
|
|
|
|
(test "channel-patching")
|
|
|
|
(test "derivation-outputs")
|
|
|
|
(test "hosts-config")
|
|
|
|
(test "overlays-flow")
|
2021-09-05 18:47:12 +03:00
|
|
|
(test "all" // { command = "check-channel-patching && 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")
|
|
|
|
(dry-nixos-build "home-manager+nur+neovim" "Rick")
|
|
|
|
(dry-nixos-build "exporters" "Morty")
|
2021-05-19 12:15:21 +03:00
|
|
|
(withCategory "dry-build" { name = "build-all"; command = "build-exporters-Morty && build-home-manager+nur+neovim-Rick && build-minimal-multichannel-Hostname1 && build-minimal-multichannel-Hostname2"; })
|
|
|
|
|
2021-05-15 16:47:15 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
}
|