-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
124 lines (112 loc) · 4.21 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
description = "the-argus nixos system configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
banner.url = "github:the-argus/banner.nix";
spicetify-nix = {
url = "github:the-argus/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
gtk-nix = {
url = "github:the-argus/gtk-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# rycee packages firefox extensions
rycee-expressions = {
url = "gitlab:rycee/nur-expressions";
flake = false;
};
# non-nix imports (need fast updates):
arkenfox-userjs = {
url = "github:arkenfox/user.js";
flake = false;
};
};
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
home-manager,
banner,
rycee-expressions,
spicetify-nix,
gtk-nix,
arkenfox-userjs,
} @ inputs: let
# import a given nixpkgs using the options generated by nixpkgs-inputs.nix.
# requires us to pass the nixpkgs lib so that nixpkgs-inputs.nix can use it,
# and banner so that it can be sent to the packages of mine that need it.
importNixpkgs = np: settings:
import np (import ./flake/nixpkgs-inputs.nix (settings
// {
lib = np.lib;
inherit banner;
}));
# this function imports the nixpkgs-inputs function to create the correct
# inputs to import nixpkgs, based on a given settings attrset. these
# attrsets are different per-host and are found in `flake/hosts`.
mkNixOSConfig = top-level:
nixpkgs.lib.nixosSystem {
pkgs = importNixpkgs nixpkgs top-level;
inherit (top-level) system;
# make information accessible as module arguments
specialArgs =
# all the flakes we're importing should be accessible
inputs
# import nixpkgs again, this time use unstable as the source. this way
# modules can use the newer versions of packages
// {unstable = importNixpkgs nixpkgs-unstable top-level;}
# some stuff from top-level.nix should be accessible, mostly used
# by the hosts/defaults/configuration.nix for stuff like users
// {inherit (top-level) username hostname stateVersion;}
# default-system-features is used by hosts/defaults/configuration.nix
# to mkDefault. all my machines have the same system features so I never
# actually have to override this default. the gccarch- option is needed
# if top-level.useArch is true, otherwise nix thinks the host cant
# run the binaries we are asking it to compile for its arch
// {default-system-features = ["nixos-test" "benchmark" "big-parallel" "kvm" "gccarch-${top-level.arch}"];};
# top-level.modules are defined in files such as hosts/laptop/top-level.nix
# it is how other nixos configuration options are imported
modules = [./hosts/defaults/system ./modules/shared ./modules/system] ++ top-level.nixosModules;
};
mkHomeManagerConfig = top-level: let
homeDirectory = "/home/${top-level.username}";
in
home-manager.lib.homeManagerConfiguration {
pkgs = importNixpkgs nixpkgs top-level;
modules =
[
# import modules, and default options for everything
./modules/user
./modules/shared
./hosts/defaults/user
# just propagate username, stateVersion, and homeDirectory immediately
({...}: {
home = {
inherit (top-level) username stateVersion;
inherit homeDirectory;
};
})
]
++ top-level.homeManagerModules;
extraSpecialArgs =
inputs
// {
inherit (top-level) username hostname stateVersion;
inherit homeDirectory;
};
};
in {
nixosConfigurations = {
laptop = mkNixOSConfig (import ./hosts/laptop/top-level.nix);
};
homeConfigurations = {
laptop = mkHomeManagerConfig (import ./hosts/laptop/top-level.nix);
};
};
}