-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
70 lines (57 loc) · 2.32 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
{
inputs = {
nixos.url = "github:NixOS/nixpkgs/nixos-24.11";
nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-gaming.url = "github:fufexan/nix-gaming";
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixos";
};
opentabletdriver.url = "github:OpenTabletDriver/OpenTabletDriver";
};
outputs = inputs @ { self, nixos, nixos-unstable, home-manager, ... }: let
inherit (builtins) baseNameOf attrValues;
inherit (lib) nixosSystem genAttrs;
inherit (lib.my) mapHosts forAllSystems;
inherit (lib.my.modules) mapModules mapModules' mapModulesRec mapModulesRec';
lib = nixos.lib.extend (self: super: {
my = import ./lib (inputs // { inherit lib; });
});
# Helper function to configure nixpkgs for a given system
configureNixpkgs = nixpkgs: system: import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = (attrValues self.overlays) ++ [ self.overlay ];
};
in rec {
# nixpkgs instantiated for all supported systems
nixpkgsFor = forAllSystems (system: configureNixpkgs nixos system);
overlay = final: prev: {
user = self.packages.${final.system} // { inherit lib; };
unstable = configureNixpkgs nixos-unstable final.system;
nix-gaming = inputs.nix-gaming.packages.${final.system};
};
overlays = mapModules ./overlays import;
packages = forAllSystems (system: mapModules ./pkgs (p: nixpkgsFor.${system}.callPackage p {}));
nixosModules = mapModulesRec ./modules/system import;
nixosConfigurations = mapHosts ./hosts
(name: system: nixosSystem {
specialArgs = { inherit lib inputs system; flake = self; };
modules = [
./hosts/default.nix # shared system config
./hosts/${name} # host specific config
home-manager.nixosModule
{
networking.hostName = name; # set hostname
nixpkgs = {
hostPlatform = system;
pkgs = nixpkgsFor.${system};
};
imports = (mapModulesRec' ./modules/system import) # system modules
++ (mapModules' ./users import); # user configurations
}
];
});
devShell = forAllSystems (system: import ./shell.nix { inherit system; flake = self; });
};
}