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="
16 doom-emacs.flake = false;
17 doom-emacs.url = "github:hlissner/doom-emacs";
20 url = "github:martintrojer/jj-fugitive";
24 url = "github:sivansh11/jj";
28 url = "github:BibekBhusal0/bufstack.nvim";
32 url = "github:rafikdraoui/jj-diffconflicts";
36 url = "github:NicolasGB/jj.nvim";
37 #url = "git+file:///home/julm/src/lua/jj.nvim";
40 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
41 git-hooks.url = "github:cachix/git-hooks.nix";
42 home-manager.inputs.nixpkgs.follows = "nixpkgs";
43 home-manager.url = "github:nix-community/home-manager/release-25.11";
44 #home-manager.url = "git+file:///home/julm/src/nix/home-manager";
45 nixos-hardware.url = "github:NixOS/nixos-hardware/master";
46 #nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
47 nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
48 nixpkgs-unstable.url = "github:NixOS/nixpkgs/master";
49 nixpkgs-unstable-latest.url = "github:NixOS/nixpkgs/a3a2ddee4adfb361bdfe2e915c7e85c2e71cfc5f";
51 url = "github:nix-community/lanzaboote/v0.4.2";
52 inputs.nixpkgs.follows = "nixpkgs";
53 inputs.pre-commit-hooks-nix.follows = "git-hooks";
60 remoteNixpkgsPatches = import nixpkgs/patches.nix;
61 localNixpkgsPatches = [
62 nixpkgs/patches/openvpn/openvpn-netns.patch
63 nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch
65 originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux";
66 nixpkgsPath = originPkgs.applyPatches {
67 name = "nixpkgs-patched";
68 src = inputs.nixpkgs.outPath;
69 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
71 patch=$(printf '%s\n' ${
72 builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)
74 sort | sha256sum | cut -c -7)
75 echo "-patch-$patch" >.version-suffix
78 profile = "/nix/var/nix/profiles/system";
79 inherit (inputs.nixpkgs) lib;
80 overlays = _system: import nixpkgs/overlays.nix;
81 #nixosSystem = lib.nixosSystem;
82 nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix");
85 lib.genAttrs lib.systems.flakeExposed (
89 #pkgs = inputs.nixpkgs.legacyPackages.${system};
90 pkgs = import nixpkgsPath {
92 overlays = overlays system;
125 (fileFilter (file: lib.any file.hasExt exts) ./domains)
126 (fileFilter (file: lib.any file.hasExt exts) ./home-manager)
127 (fileFilter (file: lib.any file.hasExt exts) ./homes)
128 (fileFilter (file: lib.any file.hasExt exts) ./hosts)
129 (fileFilter (file: lib.any file.hasExt exts) ./nixos)
130 (fileFilter (file: lib.any file.hasExt exts) ./nixpkgs)
131 (fileFilter (file: lib.any file.hasExt exts) ./users)
137 # nix -L build .#hello
138 packages = forAllSystems ({ pkgs, ... }: pkgs);
140 # nix -L build .#nixosConfigurations.oignon.config.system.build.toplevel
141 # nix -L build .#nixosConfigurations.oignon.config.boot.kernelPackages.kernel.configfile
142 # nix -L build .#nixosConfigurations.oignon.pkgs.hello
143 # nix eval --raw .#nixosConfigurations.oignon.config.networking.nftables.ruleset
144 nixosConfigurations =
146 (builtins.attrNames (
147 lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (self + "/hosts"))
154 # Required to avoid infinite recursion
155 # when `inputs` is used in `imports`.
160 (import (self + "/hosts/${hostName}.nix"))
161 inputs.lanzaboote.nixosModules.lanzaboote
162 inputs.home-manager.nixosModules.home-manager
166 inherit (config.nixpkgs.hostPlatform) system;
167 pkgs-unstable = import inputs.nixpkgs-unstable.outPath {
169 overlays = overlays system;
171 pkgs-unstable-latest = import inputs.nixpkgs-unstable-latest.outPath {
173 overlays = overlays system;
178 inherit hostName pkgs-unstable pkgs-unstable-latest;
179 hosts = nixosConfigurations;
180 host = nixosConfigurations.${hostName}._module.args;
183 overlays = overlays config.nixpkgs.hostPlatform.system;
184 config.permittedInsecurePackages = [
185 # Still needed for chatty
186 # See https://github.com/NixOS/nixpkgs/pull/334638#issuecomment-2289025802%3E
187 # and https://gitlab.gnome.org/World/Chatty/-/issues/932
190 config.allowUnfreePredicate =
192 builtins.elem (lib.getName pkg) [
204 useGlobalPkgs = true;
205 useUserPackages = true;
208 backupFileExtension = "old";
224 # nix -L develop or direnv allow
225 devShells = forAllSystems (
226 { pkgs, system, ... }:
228 default = pkgs.callPackage (self + "/shell.nix") {
235 inherit (checks.${system}.git-hooks-check) shellHook;
240 # nix -L run .#oignon.switch
241 apps = forAllSystems (
242 { pkgs, system, ... }:
248 inherit (config.system) build;
249 scriptApp = scriptName: ps: script: {
252 (pkgs.writeShellScript "${hostName}-${scriptName}" ''
253 export PATH="${lib.makeBinPath ([ pkgs.coreutils ] ++ ps)}:$PATH"
260 # Example: nix run .#aubergine.switch
261 "switch" = scriptApp "switch" [ ] ''
264 chmod -R g-rwx,o-rwx **/*.gpg
265 trap 'git reset **/*.gpg' EXIT
266 git rm -rf --cached --ignore-unmatch **/*.gpg # prevent copying to /nix/store
268 nix-store --add-root hosts/${hostName}.nixpkgs --indirect --realise ${nixpkgsPath}
269 nix-store --add-root hosts/${hostName}.root --indirect --realise ${build.toplevel}
271 nix copy --to "ssh://${config.install.target}?''${targetStore-}"${lib.optionalString config.install.substituteOnDestination " --substitute-on-destination"} ${build.toplevel}
273 if ssh ${config.install.target} set -x ';' \
274 systemctl reset-failed nixos-fallback '2>/dev/null' ';' \
275 test "''${NO_NIXOS_FALLBACK:+set}" '||' \
276 systemd-run -u nixos-fallback --description=nixos-fallback /bin/sh -xc '''\'''
286 ${profile}/bin/switch-to-configuration switch
289 ${build.toplevel}/bin/switch-to-configuration test
291 ssh ${config.install.target} -o ControlPath=none set -x ';' \
292 systemctl stop nixos-fallback.service ';' \
293 nix-env --profile ${profile} --set '${build.toplevel}' ';' \
294 ${build.toplevel}/bin/switch-to-configuration boot '&&' \
295 nix-env --delete-generations 7d --profile ${profile}
298 echo WARNING: switch-to-configuration was not registered at boot
300 ssh ${config.install.target} -o ControlPath=none set -x ';' \
301 systemctl stop nixos-fallback.service
306 ) nixosConfigurations
310 checks = forAllSystems (
312 git-hooks-check = inputs.git-hooks.lib.${system}.run {
315 nixfmt-rfc-style.enable = true;