-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
76 lines (67 loc) · 1.8 KB
/
flake.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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
impermanence.url = "github:nix-community/impermanence";
};
outputs =
{
self,
nixpkgs,
impermanence,
}:
let
inherit (nixpkgs) lib;
mypkgs =
pkgs:
self.lib.dirToAttrs ./pkgs (x: pkgs.callPackage x { })
// {
iso = import lib/gen-iso.nix lib pkgs.system;
};
forAllSystems = lib.genAttrs [ "x86_64-linux" ];
pins = {
nix.registry.nixpkgs.to = {
inherit (nixpkgs) rev;
owner = "NixOS";
repo = "nixpkgs";
type = "github";
};
nix.registry.bck.to = {
owner = "buckley310";
repo = "nixos-config";
type = "github";
};
};
in
{
lib = {
base64 = import lib/base64.nix;
gen-ssh-config = import lib/gen-ssh-config.nix lib;
ssh-keys = import lib/ssh-keys.nix;
dirToAttrs =
dir: f:
lib.mapAttrs' (name: _: {
name = lib.removeSuffix ".nix" name;
value = f "${toString dir}/${name}";
}) (builtins.readDir dir);
};
nixosModules = self.lib.dirToAttrs ./modules import // {
inherit pins;
inherit (impermanence.nixosModules) impermanence;
pkgs.nixpkgs.overlays = [ (_: mypkgs) ];
};
nixosConfigurations = self.lib.dirToAttrs ./hosts (
dir:
let
cfg = import dir;
in
lib.nixosSystem {
inherit (cfg) system;
modules =
cfg.modules
++ [ { networking.hostName = builtins.baseNameOf dir; } ]
++ (builtins.attrValues self.nixosModules);
}
);
packages = forAllSystems (system: mypkgs nixpkgs.legacyPackages.${system});
};
}