-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
171 lines (143 loc) · 5.81 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
description = "NixOS and Home-Manager configurations";
inputs = {
nixpkgs-24-05.url = "nixpkgs/nixos-24.05";
nixpkgs.url = "nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager/release-24.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.url = "github:nix-community/plasma-manager";
plasma-manager.inputs.nixpkgs.follows = "nixpkgs";
plasma-manager.inputs.home-manager.follows = "home-manager";
emacs-overlay.url = "github:nix-community/emacs-overlay";
nix-doom-emacs-unstraightened.url = "github:marienz/nix-doom-emacs-unstraightened";
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:LnL7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
devshell.url = "github:numtide/devshell";
deploy-rs.url = "github:serokell/deploy-rs";
authentik-nix.url = "github:nix-community/authentik-nix";
emacs-lsp-booster.url = "github:slotThe/emacs-lsp-booster-flake";
};
outputs =
{ self
, nixpkgs
, nixpkgs-unstable
, home-manager
, sops-nix
, flake-utils
, flake-utils-plus
, deploy-rs
, authentik-nix
, emacs-lsp-booster
, ...
} @ inputs:
let
supportedSystems = [ "x86_64-linux" "aarch64-darwin" ];
lib = nixpkgs.lib.extend
(self: super: {
my = import ./lib { inherit inputs; lib = self; pkgs = nixpkgs; };
hm = home-manager.lib;
});
inherit (lib.my) mapModules;
pkgs = self.pkgs.x86_64-linux.nixpkgs;
nixosHosts = mapModules ./hosts/nixos (hostPath: lib.my.mkHostAttrs hostPath {
system = "x86_64-linux";
modules = lib.my.mapModulesRec' (toString ./modules/nixos) import;
});
# darwinHosts = mapModules ./hosts/darwin (hostPath: lib.my.mkHostAttrs hostPath {
# system = "aarch64-darwin";
# modules = lib.my.mapModulesRec' (toString ./modules/darwin) import;
# });
in
flake-utils-plus.lib.mkFlake
rec {
inherit lib self inputs supportedSystems;
channels.nixpkgs-unstable.config = { allowUnfree = true; };
channels.nixpkgs.config = { allowUnfree = true; };
hostDefaults = {
channelName = "nixpkgs";
modules = [
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
authentik-nix.nixosModules.default
] ++ lib.my.mapModulesRec' (toString ./modules/shared) import;
};
sharedOverlays = [
(final: prev: {
unstable = import nixpkgs-unstable {
system = prev.system;
config.allowUnfree = true;
};
my = self.packages."${prev.system}";
# Keep 24.05 bitwarden-cli as there are some build issues with the new one
bitwarden-cli = inputs.nixpkgs-24-05.legacyPackages.${prev.system}.bitwarden-cli;
# Temporary fix as I can't switch to 24.11 yet
# ghostscript = nixpkgs-unstable.legacyPackages.${prev.system}.ghostscript;
})
inputs.devshell.overlays.default
inputs.emacs-overlay.overlays.default
emacs-lsp-booster.overlays.default
];
hosts = nixosHosts;
outputsBuilder = channels: rec {
inherit channels;
packages = lib.foldAttrs (item: acc: item) { }
(lib.attrValues (mapModules ./packages (p: import p {
inherit lib inputs;
pkgs = channels.nixpkgs;
}))) // {
testTandoor = pkgs.testers.runNixOSTest ./tests/tandoor.nix;
testPaperless = pkgs.testers.runNixOSTest ./tests/paperless.nix;
};
apps = (lib.mapAttrs' (name: value: { inherit name; value = lib.my.mkApp value; }) packages) // {
default = apps.flakeRepl;
};
devShells = {
default = import ./shell.nix { pkgs = channels.nixpkgs; };
};
formatter = pkgs.nixpkgs-fmt;
};
homeConfigurations = lib.my.mergeAttrs (lib.forEach supportedSystems (system:
let
isDarwin = (system == "x86_64-darwin" || system == "aarch64-darwin");
user = if (isDarwin) then "tibor.pilz" else "tibor";
homeDirectory = if (isDarwin) then "/Users/${user}" else "/home/${user}";
pkgs = self.channels.${system}.nixpkgs;
enableSyncthing = (system == "x86_64-linux");
hosts = lib.attrNames self.nixosConfigurations;
mkHostAliases = map (h: "${user}@${h}") hosts;
aliases = mkHostAliases;
homeConfiguration = home-manager.lib.homeManagerConfiguration {
inherit lib pkgs;
modules = [
./home
inputs.nix-doom-emacs-unstraightened.hmModule
{
_module.args.inputs = inputs;
home.username = user;
home.homeDirectory = homeDirectory;
modules.syncthing.service = enableSyncthing;
nix.package = pkgs.nix;
}
];
};
aliasConfigurations = lib.foldr (curr: prev: prev // { "${curr}" = homeConfiguration; }) { } aliases;
in
{ "${user}" = homeConfiguration; } // aliasConfigurations
));
nixosModules = lib.my.mapModulesRec (toString ./modules) import;
} // {
deploy.nodes.klaus = {
hostname = "klaus";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.klaus;
remoteBuild = true;
};
};
};
}