blob: 4508e5827dfdd0195118fc353b3df72d12cc31b2 (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixos-hardware.url = "github:NixOS/nixos-hardware/master";
inputs.emacs-overlay.url = "github:nix-community/emacs-overlay";
inputs.agenix.url = "github:ryantm/agenix";
inputs.agenix.inputs.nixpkgs.follows = "nixpkgs";
outputs =
{ self, nixpkgs, nixpkgs-unstable, nixos-hardware, emacs-overlay, agenix }:
let
pkgs-module = { config, ... }:
let
cfg = config.nixpkgs;
extra-packages = final: prev: {
agenix = agenix.packages.${final.system}.default;
};
unstable-overlay = final: prev: rec {
unstable = import nixpkgs-unstable {
inherit (cfg) config localSystem crossSystem;
};
};
in {
nixpkgs.pkgs = import nixpkgs {
inherit (cfg) config localSystem crossSystem;
overlays = cfg.overlays
++ [ unstable-overlay extra-packages emacs-overlay.overlay ];
};
};
registry-module = { ... }: {
nix.registry.nixpkgs.flake = nixpkgs;
nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable;
};
lib = nixpkgs.lib;
orbekk-modules = let
moduleFiles = lib.attrNames
(lib.filterAttrs (n: v: lib.hasSuffix ".nix" n && v == "regular")
(builtins.readDir ./modules));
moduleNames = map (lib.removeSuffix ".nix") moduleFiles;
mkModule = name: {
inherit name;
value = import (./. + "/modules/${name}.nix");
};
in lib.listToAttrs (map mkModule moduleNames);
in {
nixosModules = orbekk-modules // { inherit pkgs-module registry-module; };
packages."x86_64-linux" =
let pkgs = import nixpkgs { system = "x86_64-linux"; };
in { };
nixosConfigurations = let
mkConfig = { hostName, module ? (./. + "/machines/${hostName}.nix")
, system ? "x86_64-linux" }: {
name = hostName;
value = lib.nixosSystem {
inherit system;
modules = (lib.attrValues self.nixosModules) ++ [
pkgs-module
registry-module
module
nixpkgs.nixosModules.notDetected
agenix.nixosModules.default
({ config, pkgs, ... }: {
# Let 'nixos-version --json' know about the Git revision
# of this flake.
system.configurationRevision = let
lastModified = pkgs.lib.substring 0 8
(self.lastModifiedDate or self.lastModified or "19700101");
in "${lastModified}.${self.shortRev or "dirty"}";
})
];
};
};
myMachines = [
{
hostName = "pincer";
module = ./machines/x1-pincer.nix;
}
{ hostName = "dragon"; }
{ hostName = "firelink"; }
{ hostName = "tiny1"; }
{
hostName = "minideck";
}
# { hostName = "testvm"; module = {
# users.users.orbekk.initialHashedPassword = "";
# }; }
];
in builtins.listToAttrs (map mkConfig myMachines);
};
}
|