blob: 4024d9051684488f70db8bfd500ed69a872a0d2a (
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
102
103
104
105
106
107
108
|
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.09";
inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixos-hardware.url = github:NixOS/nixos-hardware/master;
inputs.home-manager.url = "github:rycee/home-manager/master";
inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
# TODO: Remove nix overlay when pull request is resolved:
# https://github.com/NixOS/nix/pull/4566
inputs.nix.url = "github:orbekk/nix/master";
inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nixpkgs-unstable, nix, nixos-hardware, home-manager }:
let
pkgs-module = {config, ...}:
let
cfg = config.nixpkgs;
unstable-overlay = final: prev: {
unstable = import nixpkgs-unstable {
inherit (cfg) config localSystem crossSystem;
};
};
in {
nixpkgs.pkgs = import nixpkgs {
inherit (cfg) config localSystem crossSystem;
overlays = cfg.overlays ++ [ unstable-overlay ];
};
};
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;
};
packages."x86_64-linux" =
let
pkgs = import nixpkgs {
system = "x86_64-linux";
};
in
{
nftables-exporter = pkgs.callPackage ./pkgs/nftables-exporter.nix {};
};
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
module
nixpkgs.nixosModules.notDetected
({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"}";
nixpkgs.overlays = [
# For git+file support with bare repo.
nix.overlay
(final: prev: { nixFlakes = final.nix; })
];
})
];
};
};
myMachines = [
{ hostName = "pincer"; module = ./machines/x1-pincer.nix; }
{ hostName = "dragon"; }
{ hostName = "firelink"; }
{ hostName = "testvm"; module = {
users.users.orbekk.initialHashedPassword = "";
}; }
];
in builtins.listToAttrs (map mkConfig myMachines);
};
}
|