2 description = "julm's Nix configurations for hosts (NixOS) and homes (home-manager)";
6 "https://nix-community.cachix.org"
8 extra-trusted-public-keys = [
9 "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
15 allow-import-from-derivation = true;
20 doom-emacs.flake = false;
21 doom-emacs.url = "github:hlissner/doom-emacs";
24 url = "github:martintrojer/jj-fugitive";
28 url = "github:sivansh11/jj";
32 url = "github:BibekBhusal0/bufstack.nvim";
36 url = "github:rafikdraoui/jj-diffconflicts";
40 url = "github:NicolasGB/jj.nvim";
41 #url = "git+file:///home/julm/src/lua/jj.nvim";
44 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
45 git-hooks.url = "github:cachix/git-hooks.nix";
46 home-manager.inputs.nixpkgs.follows = "nixpkgs";
47 home-manager.url = "github:nix-community/home-manager/release-25.11";
48 #home-manager.url = "git+file:///home/julm/src/nix/home-manager";
49 nixos-hardware.url = "github:NixOS/nixos-hardware/master";
50 #nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
51 nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
52 nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
53 nixpkgs-unstable-latest.url = "github:NixOS/nixpkgs/cad22e7d996aea55ecab064e84834289143e44a0";
55 url = "github:nix-community/lanzaboote/v1.0.0";
56 inputs.nixpkgs.follows = "nixpkgs";
57 inputs.pre-commit.follows = "git-hooks";
64 remoteNixpkgsPatches = import nixpkgs/patches.nix;
65 localNixpkgsPatches = [
66 nixpkgs/patches/openvpn/openvpn-netns.patch
67 nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch
69 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
70 nixpkgsPath = originPkgs.applyPatches {
71 name = "nixpkgs-patched";
72 src = inputs.nixpkgs.outPath;
73 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
75 patch=$(printf '%s\n' ${
76 builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)
78 sort | sha256sum | cut -c -7)
79 echo "-patch-$patch" >.version-suffix
82 profile = "/nix/var/nix/profiles/system";
83 inherit (inputs.nixpkgs) lib;
84 overlays = _system: import nixpkgs/overlays.nix;
85 #nixosSystem = lib.nixosSystem;
86 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
89 lib.genAttrs lib.systems.flakeExposed (
93 #pkgs = inputs.nixpkgs.legacyPackages.${system};
94 pkgs = import nixpkgsPath {
96 overlays = overlays system;
129 (fileFilter (file: lib.any file.hasExt exts) ./domains)
130 (fileFilter (file: lib.any file.hasExt exts) ./home-manager)
131 (fileFilter (file: lib.any file.hasExt exts) ./homes)
132 (fileFilter (file: lib.any file.hasExt exts) ./hosts)
133 (fileFilter (file: lib.any file.hasExt exts) ./nixos)
134 (fileFilter (file: lib.any file.hasExt exts) ./nixpkgs)
135 (fileFilter (file: lib.any file.hasExt exts) ./users)
141 # nix -L build .#hello
142 packages = forAllSystems ({ pkgs, ... }: pkgs);
144 # nix -L build .#nixosConfigurations.oignon.config.system.build.toplevel
145 # nix -L build .#nixosConfigurations.oignon.config.boot.kernelPackages.kernel.configfile
146 # nix -L build .#nixosConfigurations.oignon.pkgs.hello
147 # nix eval --raw .#nixosConfigurations.oignon.config.networking.nftables.ruleset
148 nixosConfigurations =
150 (builtins.attrNames (
151 lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (self + "/hosts"))
158 # Required to avoid infinite recursion
159 # when `inputs` is used in `imports`.
164 (import (self + "/hosts/${hostName}.nix"))
165 inputs.lanzaboote.nixosModules.lanzaboote
166 inputs.home-manager.nixosModules.home-manager
170 inherit (config.nixpkgs.hostPlatform) system;
171 pkgs-unstable = import inputs.nixpkgs-unstable.outPath {
173 overlays = overlays system;
175 pkgs-unstable-latest = import inputs.nixpkgs-unstable-latest.outPath {
177 overlays = overlays system;
182 inherit hostName pkgs-unstable pkgs-unstable-latest;
183 hosts = nixosConfigurations;
184 host = nixosConfigurations.${hostName}._module.args;
187 overlays = overlays config.nixpkgs.hostPlatform.system;
188 config.permittedInsecurePackages = [
189 # Still needed for chatty
190 # See https://github.com/NixOS/nixpkgs/pull/334638#issuecomment-2289025802%3E
191 # and https://gitlab.gnome.org/World/Chatty/-/issues/932
194 config.allowUnfreePredicate =
196 builtins.elem (lib.getName pkg) [
208 useGlobalPkgs = true;
209 useUserPackages = true;
212 backupFileExtension = "old";
228 # nix -L develop or direnv allow
229 devShells = forAllSystems (
230 { pkgs, system, ... }:
232 default = pkgs.callPackage (self + "/shell.nix") {
239 inherit (checks.${system}.git-hooks-check) shellHook;
244 # nix -L run .#oignon.switch
245 apps = forAllSystems (
246 { pkgs, system, ... }:
252 inherit (config.system) build;
253 scriptApp = scriptName: ps: script: {
256 (pkgs.writeShellScript "${hostName}-${scriptName}" ''
257 export PATH="${lib.makeBinPath ([ pkgs.coreutils ] ++ ps)}:$PATH"
264 # Example: nix run .#aubergine.switch
265 "switch" = scriptApp "switch" [ ] ''
268 chmod -R g-rwx,o-rwx **/*.gpg
269 trap 'git reset **/*.gpg' EXIT
270 git rm -rf --cached --ignore-unmatch **/*.gpg # prevent copying to /nix/store
272 nix-store --add-root hosts/${hostName}.nixpkgs --indirect --realise ${nixpkgsPath}
273 nix-store --add-root hosts/${hostName}.root --indirect --realise ${build.toplevel}
275 nix copy --to "ssh://${config.install.target}?''${targetStore-}"${lib.optionalString config.install.substituteOnDestination " --substitute-on-destination"} ${build.toplevel}
277 if ssh ${config.install.target} set -x ';' \
278 systemctl reset-failed nixos-fallback '2>/dev/null' ';' \
279 test "''${NO_NIXOS_FALLBACK:+set}" '||' \
280 systemd-run -u nixos-fallback --description=nixos-fallback /bin/sh -xc '''\'''
290 ${profile}/bin/switch-to-configuration switch
293 ${build.toplevel}/bin/switch-to-configuration test
295 ssh ${config.install.target} -o ControlPath=none set -x ';' \
296 systemctl stop nixos-fallback.service ';' \
297 nix-env --profile ${profile} --set '${build.toplevel}' ';' \
298 ${build.toplevel}/bin/switch-to-configuration boot '&&' \
299 nix-env --delete-generations 7d --profile ${profile}
302 echo WARNING: switch-to-configuration was not registered at boot
304 ssh ${config.install.target} -o ControlPath=none set -x ';' \
305 systemctl stop nixos-fallback.service
310 ) nixosConfigurations
314 checks = forAllSystems (
316 git-hooks-check = inputs.git-hooks.lib.${system}.run {
319 nixfmt-rfc-style.enable = true;