-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathflake-module.nix
81 lines (73 loc) · 2.49 KB
/
flake-module.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ config, lib, inputs, self, withSystem, ... }:
{
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.hercules-ci-effects.flakeModule # herculesCI attr
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
hercules-ci.flake-update = {
enable = true;
autoMergeMethod = "merge";
when.dayOfMonth = 1;
flakes = {
"." = { };
"dev" = { };
};
effect.settings = {
# Only fetch the `lib` subtree.
# NOTE: Users don't have to do this. They are recommended to use follows
# and just use the `nixpkgs` they're already fetching anyway.
# It doesn't have to be `lib/` only!
git.update.script = lib.mkBefore ''
echo 'Fetching nixpkgs-lib tree'
branch="nixos-unstable"
mkdir ~/nixpkgs
git -C ~/nixpkgs init
git -C ~/nixpkgs remote add origin https://github.com/NixOS/nixpkgs.git
git -C ~/nixpkgs fetch origin --filter=blob:none --depth=1 "$branch"
commit="$(git -C ~/nixpkgs rev-parse FETCH_HEAD)"
tree="$(git -C ~/nixpkgs rev-parse FETCH_HEAD:lib)"
echo 'Adjusting nixpkgs-lib.url'
sed -i flake.nix -e \
's^ nixpkgs-lib\.url = ".*^ nixpkgs-lib\.url = "https://github.com/NixOS/nixpkgs/archive/'$tree'.tar.gz"; # '$commit' /lib from '$branch'^'
git diff
grep -F "$tree" flake.nix >/dev/null || {
echo 'failed to write new tree to flake.nix'
exit 1
}
git commit flake.nix -m 'flake.nix: Update nixpkgs-lib tree'
'';
};
};
perSystem = { config, pkgs, ... }: {
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.nixpkgs-fmt
pkgs.pre-commit
pkgs.hci
];
shellHook = ''
${config.pre-commit.installationScript}
'';
};
pre-commit = {
inherit pkgs; # should make this default to the one it can get via follows
settings = {
hooks.nixpkgs-fmt.enable = true;
};
};
checks.eval-tests =
let tests = import ./tests/eval-tests.nix { flake-parts = self; };
in tests.runTests pkgs.emptyFile // { internals = tests; };
};
flake = {
# for repl exploration / debug
config.config = config;
options.mySystem = lib.mkOption { default = config.allSystems.${builtins.currentSystem}; };
config.effects = withSystem "x86_64-linux" ({ pkgs, hci-effects, ... }: {
tests = {
template = pkgs.callPackage ./tests/template.nix { inherit hci-effects; };
};
});
};
}