-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
106 lines (98 loc) · 2.96 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
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11";
# nixpkgs-small.url = "github:NixOS/nixpkgs/nixos-unstable-small";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix.url = "github:Mic92/sops-nix";
impermanence.url = "github:nix-community/impermanence";
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
cheatsheets = {
url = "github:cheat/cheatsheets";
flake = false;
};
helix.url = "github:helix-editor/helix";
fenix.url = "github:nix-community/fenix";
nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
lanzaboote = {
url = "github:nix-community/lanzaboote/v0.4.1";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
home-manager,
...
} @ inputs: let
inherit (nixpkgs) lib;
eachDefaultSystem = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
importNixpkgs = system: nixpkgs: let
config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"discord-canary"
"obsidian"
"steam"
"steam-unwrapped"
"steam-original"
"steam-run"
"spotify"
];
in
import nixpkgs {inherit system config;};
extra-pkgs = system:
lib.pipe inputs [
(lib.filterAttrs (k: _: lib.hasPrefix "nixpkgs-" k))
(lib.mapAttrs' (k: v: {
name = lib.removePrefix "nix" k;
value = importNixpkgs system v;
}))
];
getSystemFromHardwareConfiguration = hostName: let
f = import ./hosts/${hostName}/hardware-configuration.nix;
args = builtins.functionArgs f // {lib.mkDefault = lib.id;};
in
(f args).nixpkgs.hostPlatform;
mkHost = name: system:
lib.nixosSystem {
inherit system;
pkgs = importNixpkgs system nixpkgs;
specialArgs = inputs // (extra-pkgs system);
modules = [
./hosts/${name}
./hosts/${name}/hardware-configuration.nix
./system
{networking.hostName = name;}
];
};
in {
nixosConfigurations = lib.pipe ./hosts [
builtins.readDir
(lib.filterAttrs (_: type: type == "directory"))
(builtins.mapAttrs (name: _: mkHost name (getSystemFromHardwareConfiguration name)))
];
packages = eachDefaultSystem (
system: let
pkgs = importNixpkgs system nixpkgs;
in
import ./scripts pkgs
);
checks = let
nixosConfigurations =
lib.mapAttrsToList (name: config: {
${getSystemFromHardwareConfiguration name}.${name} = config.config.system.build.toplevel;
})
self.nixosConfigurations;
in
builtins.foldl' lib.recursiveUpdate {} ([self.packages] ++ nixosConfigurations);
};
}