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 # Explanation: required due to the applyPatches on nixpkgs below.
16 allow-import-from-derivation = true;
19 # https://status.nixos.org
20 # nix flake update nixpkgs --override-flake nixpkgs github:NixOS/nixpkgs/2c3e5ec5df46d3aeee2a1da0bfedd74e21f4bf3a --allow-dirty-locks
23 url = "github:AzaharPlus/AzaharPlus?submodules=1";
27 url = "github:idursun/jjui";
31 doom-emacs.flake = false;
32 doom-emacs.url = "github:hlissner/doom-emacs";
35 url = "github:martintrojer/jj-fugitive";
39 url = "github:sivansh11/jj";
43 url = "github:BibekBhusal0/bufstack.nvim";
47 url = "github:rafikdraoui/jj-diffconflicts";
51 url = "github:NicolasGB/jj.nvim";
52 #url = "git+file:///home/julm/src/lua/jj.nvim";
55 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
56 git-hooks.url = "github:cachix/git-hooks.nix";
57 home-manager.inputs.nixpkgs.follows = "nixpkgs";
58 home-manager.url = "github:nix-community/home-manager/release-25.11";
59 #home-manager.url = "git+file:///home/julm/src/nix/home-manager";
60 nixos-hardware.url = "github:NixOS/nixos-hardware/master";
61 #nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
62 nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
63 nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
64 nixpkgs-unstable-latest.url = "github:NixOS/nixpkgs/cad22e7d996aea55ecab064e84834289143e44a0";
66 url = "github:nix-community/lanzaboote/v1.0.0";
67 inputs.nixpkgs.follows = "nixpkgs";
68 inputs.pre-commit.follows = "git-hooks";
75 remoteNixpkgsPatches = import nixpkgs/patches.nix;
76 localNixpkgsPatches = [
77 nixpkgs/patches/openvpn/openvpn-netns.patch
78 nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch
80 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
81 nixpkgsPath = originPkgs.applyPatches {
82 name = "nixpkgs-patched";
83 src = inputs.nixpkgs.outPath;
84 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
86 patch=$(printf '%s\n' ${
87 builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)
89 sort | sha256sum | cut -c -7)
90 echo "-patch-$patch" >.version-suffix
93 profile = "/nix/var/nix/profiles/system";
94 inherit (inputs.nixpkgs) lib;
95 overlays = import nixpkgs/overlays.nix;
96 #nixosSystem = lib.nixosSystem;
97 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
100 lib.genAttrs lib.systems.flakeExposed (
104 #pkgs = inputs.nixpkgs.legacyPackages.${system};
105 pkgs = import nixpkgsPath {
107 overlays = overlays { inherit inputs system; };
140 (fileFilter (file: lib.any file.hasExt exts) ./domains)
141 (fileFilter (file: lib.any file.hasExt exts) ./home-manager)
142 (fileFilter (file: lib.any file.hasExt exts) ./homes)
143 (fileFilter (file: lib.any file.hasExt exts) ./hosts)
144 (fileFilter (file: lib.any file.hasExt exts) ./nixos)
145 (fileFilter (file: lib.any file.hasExt exts) ./nixpkgs)
146 (fileFilter (file: lib.any file.hasExt exts) ./users)
152 # nix -L build .#hello
153 packages = forAllSystems ({ pkgs, ... }: pkgs);
155 # nix -L build .#nixosConfigurations.oignon.config.system.build.toplevel
156 # nix -L build .#nixosConfigurations.oignon.config.boot.kernelPackages.kernel.configfile
157 # nix -L build .#nixosConfigurations.oignon.pkgs.hello
158 # nix eval --raw .#nixosConfigurations.oignon.config.networking.nftables.ruleset
159 nixosConfigurations =
161 (builtins.attrNames (
162 lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (self + "/hosts"))
169 # Required to avoid infinite recursion
170 # when `inputs` is used in `imports`.
175 (import (self + "/hosts/${hostName}.nix"))
176 inputs.lanzaboote.nixosModules.lanzaboote
177 inputs.home-manager.nixosModules.home-manager
181 inherit (config.nixpkgs.hostPlatform) system;
182 pkgs-unstable = import inputs.nixpkgs-unstable.outPath {
184 overlays = overlays { inherit inputs system; };
186 pkgs-unstable-latest = import inputs.nixpkgs-unstable-latest.outPath {
188 overlays = overlays { inherit inputs system; };
193 inherit hostName pkgs-unstable pkgs-unstable-latest;
194 hosts = nixosConfigurations;
195 host = nixosConfigurations.${hostName}._module.args;
198 overlays = overlays {
200 inherit (config.nixpkgs.hostPlatform) system;
202 config.permittedInsecurePackages = [
203 # Still needed for chatty
204 # See https://github.com/NixOS/nixpkgs/pull/334638#issuecomment-2289025802%3E
205 # and https://gitlab.gnome.org/World/Chatty/-/issues/932
208 config.allowUnfreePredicate =
210 builtins.elem (lib.getName pkg) [
222 useGlobalPkgs = true;
223 useUserPackages = true;
226 backupFileExtension = "old";
242 # nix -L develop or direnv allow
243 devShells = forAllSystems (
244 { pkgs, system, ... }:
246 default = pkgs.callPackage (self + "/shell.nix") {
253 inherit (checks.${system}.git-hooks-check) shellHook;
258 # nix -L run .#oignon.switch
259 apps = forAllSystems (
260 { pkgs, system, ... }:
266 inherit (config.system) build;
267 scriptApp = scriptName: ps: script: {
270 (pkgs.writeShellScript "${hostName}-${scriptName}" ''
271 export PATH="${lib.makeBinPath ([ pkgs.coreutils ] ++ ps)}:$PATH"
278 # Example: nix run .#aubergine.switch
279 "switch" = scriptApp "switch" [ ] ''
282 chmod -R g-rwx,o-rwx **/*.gpg
283 trap 'git reset **/*.gpg' EXIT
284 git rm -rf --cached --ignore-unmatch **/*.gpg # prevent copying to /nix/store
286 nix-store --add-root hosts/${hostName}.nixpkgs --indirect --realise ${nixpkgsPath}
287 nix-store --add-root hosts/${hostName}.root --indirect --realise ${build.toplevel}
289 nix copy --to "ssh://${config.install.target}?''${targetStore-}"${lib.optionalString config.install.substituteOnDestination " --substitute-on-destination"} ${build.toplevel}
291 if ssh ${config.install.target} set -x ';' \
292 systemctl reset-failed nixos-fallback '2>/dev/null' ';' \
293 test "''${NO_NIXOS_FALLBACK:+set}" '||' \
294 systemd-run -u nixos-fallback --description=nixos-fallback /bin/sh -xc '''\'''
304 ${profile}/bin/switch-to-configuration switch
307 ${build.toplevel}/bin/switch-to-configuration test
309 ssh ${config.install.target} -o ControlPath=none set -x ';' \
310 systemctl stop nixos-fallback.service ';' \
311 nix-env --profile ${profile} --set '${build.toplevel}' ';' \
312 ${build.toplevel}/bin/switch-to-configuration boot '&&' \
313 nix-env --delete-generations 7d --profile ${profile}
316 echo WARNING: switch-to-configuration was not registered at boot
318 ssh ${config.install.target} -o ControlPath=none set -x ';' \
319 systemctl stop nixos-fallback.service
324 ) nixosConfigurations
328 checks = forAllSystems (
330 git-hooks-check = inputs.git-hooks.lib.${system}.run {
333 nixfmt-rfc-style.enable = true;