]> Git — Sourcephile - sourcephile-nix.git/blob - flake.nix
+user/operability(nebula)(sp): add nan2gua1
[sourcephile-nix.git] / flake.nix
1 {
2 inputs = {
3 #doom-emacs.follows = "julm-nix/doom-emacs";
4 home-manager.follows = "julm-nix/home-manager";
5 #julm-nix.inputs.nixpkgs.follows = "nixpkgs";
6 julm-nix.url = "git+file:///home/julm/work/sourcephile/nix/julm-nix?ref=main";
7 nixpkgs.follows = "julm-nix/nixpkgs";
8 #nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
9 flake-compat.follows = "julm-nix/flake-compat";
10 git-hooks.follows = "julm-nix/git-hooks";
11 bufstack.follows = "julm-nix/bufstack";
12 eagle-nvim.follows = "julm-nix/eagle-nvim";
13 jj-conflict.follows = "julm-nix/jj-conflict";
14 jj-diffconflicts.follows = "julm-nix/jj-diffconflicts";
15 jj-fugitive.follows = "julm-nix/jj-fugitive";
16 NicolasGB-jj-nvim.follows = "julm-nix/NicolasGB-jj-nvim";
17 sivansh11-jj-nvim.follows = "julm-nix/sivansh11-jj-nvim";
18 };
19
20 outputs =
21 inputs:
22 let
23 remoteNixpkgsPatches = import (inputs.julm-nix + "/nixpkgs/patches.nix");
24 localNixpkgsPatches = [
25 #nixpkgs/patches/systemd-coredump.diff
26 (inputs.julm-nix + "/nixpkgs/patches/openvpn/openvpn-netns.patch")
27 (
28 inputs.julm-nix
29 + "/nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch"
30 )
31 ];
32 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
33 nixpkgsPath = originPkgs.applyPatches {
34 name = "nixpkgs-patched";
35 src = inputs.nixpkgs;
36 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
37 postPatch = ''
38 patch=$(printf '%s\n' ${
39 builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)
40 } |
41 sort | sha256sum | cut -c -7)
42 echo "-patch-$patch" >.version-suffix
43 '';
44 };
45 profile = "/nix/var/nix/profiles/system";
46 inherit (inputs.nixpkgs) lib;
47 overlays =
48 args:
49 [
50 (finalPkgs: previousPkgs: { })
51 ]
52 ++ import (inputs.julm-nix + "/nixpkgs/overlays.nix") args
53 ++ import nixpkgs/overlays.nix args;
54 #nixosSystem = lib.nixosSystem;
55 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
56 forAllSystems =
57 f:
58 lib.genAttrs lib.systems.flakeExposed (
59 system:
60 f rec {
61 inherit system;
62 #pkgs = inputs.nixpkgs.legacyPackages.${system};
63 pkgs = import nixpkgsPath {
64 inherit system;
65 overlays = overlays { inherit inputs system; };
66 };
67 }
68 );
69 in
70 {
71 # nix -L build .#hello
72 packages = forAllSystems (args: with args; pkgs);
73
74 # nix -L build .#nixosConfigurations.mermet.config.system.build.toplevel
75 # nix -L build .#nixosConfigurations.mermet.config.boot.kernelPackages.kernel.configfile
76 # nix -L build .#nixosConfigurations.mermet.pkgs.hello
77 # nix eval --raw .#nixosConfigurations.mermet.config.networking.nftables.ruleset
78 nixosConfigurations =
79 lib.genAttrs
80 (builtins.attrNames (
81 lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (inputs.self + "/hosts"))
82 ))
83 (
84 hostName:
85 nixosSystem {
86 system = null;
87 specialArgs = {
88 # Required to avoid infinite recursion
89 # when `inputs` is used in `imports`.
90 inherit inputs;
91 };
92 modules = [
93 nixos/default.nix
94 (inputs.julm-nix + "/nixos/default.nix")
95 (inputs.self + "/hosts/${hostName}.nix")
96 (
97 { config, ... }:
98 {
99 _module.args = {
100 inherit hostName;
101 hosts = inputs.self.nixosConfigurations;
102 host = inputs.self.nixosConfigurations.${hostName}._module.args;
103 info = import ./info.nix;
104 };
105 nixpkgs.overlays = overlays {
106 inherit inputs;
107 inherit (config.nixpkgs.hostPlatform) system;
108 };
109 #nixpkgs.buildPlatform = "x86_64-linux";
110 nixpkgs.config.allowUnfreePredicate =
111 pkg:
112 builtins.elem (lib.getName pkg) [
113 "canon-cups-ufr2"
114 "hplip"
115 ];
116 }
117 )
118 inputs.nixpkgs.nixosModules.notDetected
119 inputs.home-manager.nixosModules.home-manager
120 {
121 home-manager.useGlobalPkgs = true;
122 home-manager.useUserPackages = true;
123 home-manager.verbose = true;
124 home-manager.backupFileExtension = null;
125 home-manager.extraSpecialArgs = {
126 inherit hostName inputs;
127 };
128 }
129 {
130 programs.ssh.knownHosts = {
131 carotte = {
132 extraHostNames = [
133 "carotte"
134 "carotte.sourcephile.fr"
135 ];
136 publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKnnS0w9zm5KuWwlfJu+qEXC0asESQySPp76szyMTE3J";
137 };
138 mermet = {
139 extraHostNames = [
140 "mermet"
141 "mermet.sourcephile.fr"
142 ];
143 publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFvKN2sIpH782MFjaOpcty1Hs/T/TPNJpXI08H3O3oxl";
144 };
145 losurdo = {
146 extraHostNames = [
147 "losurdo"
148 "losurdo.sourcephile.fr"
149 ];
150 publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHJkAq1T0Dxozt4RPylvWrUmeuejiG+n/owb3ucnWP9F";
151 };
152 };
153 }
154 ];
155 }
156 );
157
158 # nix -L develop or direnv allow
159 devShell = forAllSystems (
160 { pkgs, system, ... }:
161 pkgs.callPackage ./shell.nix {
162 inherit
163 pkgs
164 inputs
165 system
166 nixpkgsPath
167 ;
168 inherit (inputs.self.checks.${system}.git-hooks-check) shellHook;
169 }
170 );
171
172 apps = forAllSystems (
173 { pkgs, system, ... }:
174 builtins.mapAttrs (
175 hostName:
176 { config, ... }:
177 {
178 # Example: nix run .#mermet.switch
179 "switch" = {
180 type = "app";
181 program =
182 (pkgs.callPackage (inputs.julm-nix + "/flake/apps/switch.nix") {
183 inherit
184 config
185 hostName
186 nixpkgsPath
187 profile
188 ;
189 inherit (config.system) build;
190 }).outPath;
191 };
192 }
193 ) inputs.self.nixosConfigurations
194 );
195
196 # nix flake check
197 checks = forAllSystems (
198 args: with args; {
199 git-hooks-check = inputs.git-hooks.lib.${system}.run {
200 src = inputs.self;
201 hooks = {
202 nixfmt.enable = true;
203 };
204 };
205 }
206 );
207
208 };
209 }