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 url = "github:AzaharPlus/AzaharPlus?submodules=1";
24 doom-emacs.flake = false;
25 doom-emacs.url = "github:hlissner/doom-emacs";
28 url = "github:martintrojer/jj-fugitive";
32 url = "github:sivansh11/jj";
36 url = "github:BibekBhusal0/bufstack.nvim";
40 url = "github:rafikdraoui/jj-diffconflicts";
44 url = "github:NicolasGB/jj.nvim";
45 #url = "git+file:///home/julm/src/lua/jj.nvim";
48 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
49 git-hooks.url = "github:cachix/git-hooks.nix";
50 home-manager.inputs.nixpkgs.follows = "nixpkgs";
51 home-manager.url = "github:nix-community/home-manager/release-25.11";
52 #home-manager.url = "git+file:///home/julm/src/nix/home-manager";
53 nixos-hardware.url = "github:NixOS/nixos-hardware/master";
54 #nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
55 nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
56 nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
57 nixpkgs-unstable-latest.url = "github:NixOS/nixpkgs/cad22e7d996aea55ecab064e84834289143e44a0";
59 url = "github:nix-community/lanzaboote/v1.0.0";
60 inputs.nixpkgs.follows = "nixpkgs";
61 inputs.pre-commit.follows = "git-hooks";
68 remoteNixpkgsPatches = import nixpkgs/patches.nix;
69 localNixpkgsPatches = [
70 nixpkgs/patches/openvpn/openvpn-netns.patch
71 nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch
73 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
74 nixpkgsPath = originPkgs.applyPatches {
75 name = "nixpkgs-patched";
76 src = inputs.nixpkgs.outPath;
77 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
79 patch=$(printf '%s\n' ${
80 builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)
82 sort | sha256sum | cut -c -7)
83 echo "-patch-$patch" >.version-suffix
86 profile = "/nix/var/nix/profiles/system";
87 inherit (inputs.nixpkgs) lib;
88 overlays = import nixpkgs/overlays.nix;
89 #nixosSystem = lib.nixosSystem;
90 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
93 lib.genAttrs lib.systems.flakeExposed (
97 #pkgs = inputs.nixpkgs.legacyPackages.${system};
98 pkgs = import nixpkgsPath {
100 overlays = overlays { inherit inputs system; };
133 (fileFilter (file: lib.any file.hasExt exts) ./domains)
134 (fileFilter (file: lib.any file.hasExt exts) ./home-manager)
135 (fileFilter (file: lib.any file.hasExt exts) ./homes)
136 (fileFilter (file: lib.any file.hasExt exts) ./hosts)
137 (fileFilter (file: lib.any file.hasExt exts) ./nixos)
138 (fileFilter (file: lib.any file.hasExt exts) ./nixpkgs)
139 (fileFilter (file: lib.any file.hasExt exts) ./users)
145 # nix -L build .#hello
146 packages = forAllSystems ({ pkgs, ... }: pkgs);
148 # nix -L build .#nixosConfigurations.oignon.config.system.build.toplevel
149 # nix -L build .#nixosConfigurations.oignon.config.boot.kernelPackages.kernel.configfile
150 # nix -L build .#nixosConfigurations.oignon.pkgs.hello
151 # nix eval --raw .#nixosConfigurations.oignon.config.networking.nftables.ruleset
152 nixosConfigurations =
154 (builtins.attrNames (
155 lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (self + "/hosts"))
162 # Required to avoid infinite recursion
163 # when `inputs` is used in `imports`.
168 (import (self + "/hosts/${hostName}.nix"))
169 inputs.lanzaboote.nixosModules.lanzaboote
170 inputs.home-manager.nixosModules.home-manager
174 inherit (config.nixpkgs.hostPlatform) system;
175 pkgs-unstable = import inputs.nixpkgs-unstable.outPath {
177 overlays = overlays { inherit inputs system; };
179 pkgs-unstable-latest = import inputs.nixpkgs-unstable-latest.outPath {
181 overlays = overlays { inherit inputs system; };
186 inherit hostName pkgs-unstable pkgs-unstable-latest;
187 hosts = nixosConfigurations;
188 host = nixosConfigurations.${hostName}._module.args;
191 overlays = overlays {
193 inherit (config.nixpkgs.hostPlatform) system;
195 config.permittedInsecurePackages = [
196 # Still needed for chatty
197 # See https://github.com/NixOS/nixpkgs/pull/334638#issuecomment-2289025802%3E
198 # and https://gitlab.gnome.org/World/Chatty/-/issues/932
201 config.allowUnfreePredicate =
203 builtins.elem (lib.getName pkg) [
215 useGlobalPkgs = true;
216 useUserPackages = true;
219 backupFileExtension = "old";
235 # nix -L develop or direnv allow
236 devShells = forAllSystems (
237 { pkgs, system, ... }:
239 default = pkgs.callPackage (self + "/shell.nix") {
246 inherit (checks.${system}.git-hooks-check) shellHook;
251 # nix -L run .#oignon.switch
252 apps = forAllSystems (
253 { pkgs, system, ... }:
259 inherit (config.system) build;
260 scriptApp = scriptName: ps: script: {
263 (pkgs.writeShellScript "${hostName}-${scriptName}" ''
264 export PATH="${lib.makeBinPath ([ pkgs.coreutils ] ++ ps)}:$PATH"
271 # Example: nix run .#aubergine.switch
272 "switch" = scriptApp "switch" [ ] ''
275 chmod -R g-rwx,o-rwx **/*.gpg
276 trap 'git reset **/*.gpg' EXIT
277 git rm -rf --cached --ignore-unmatch **/*.gpg # prevent copying to /nix/store
279 nix-store --add-root hosts/${hostName}.nixpkgs --indirect --realise ${nixpkgsPath}
280 nix-store --add-root hosts/${hostName}.root --indirect --realise ${build.toplevel}
282 nix copy --to "ssh://${config.install.target}?''${targetStore-}"${lib.optionalString config.install.substituteOnDestination " --substitute-on-destination"} ${build.toplevel}
284 if ssh ${config.install.target} set -x ';' \
285 systemctl reset-failed nixos-fallback '2>/dev/null' ';' \
286 test "''${NO_NIXOS_FALLBACK:+set}" '||' \
287 systemd-run -u nixos-fallback --description=nixos-fallback /bin/sh -xc '''\'''
297 ${profile}/bin/switch-to-configuration switch
300 ${build.toplevel}/bin/switch-to-configuration test
302 ssh ${config.install.target} -o ControlPath=none set -x ';' \
303 systemctl stop nixos-fallback.service ';' \
304 nix-env --profile ${profile} --set '${build.toplevel}' ';' \
305 ${build.toplevel}/bin/switch-to-configuration boot '&&' \
306 nix-env --delete-generations 7d --profile ${profile}
309 echo WARNING: switch-to-configuration was not registered at boot
311 ssh ${config.install.target} -o ControlPath=none set -x ';' \
312 systemctl stop nixos-fallback.service
317 ) nixosConfigurations
321 checks = forAllSystems (
323 git-hooks-check = inputs.git-hooks.lib.${system}.run {
326 nixfmt-rfc-style.enable = true;