{ inputs = { #doom-emacs.follows = "julm-nix/doom-emacs"; home-manager.follows = "julm-nix/home-manager"; #julm-nix.inputs.nixpkgs.follows = "nixpkgs"; julm-nix.url = "git+file:///home/julm/work/sourcephile/nix/julm-nix?ref=main"; nixpkgs.follows = "julm-nix/nixpkgs"; #nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; flake-compat.follows = "julm-nix/flake-compat"; git-hooks.follows = "julm-nix/git-hooks"; bufstack.follows = "julm-nix/bufstack"; eagle-nvim.follows = "julm-nix/eagle-nvim"; jj-conflict.follows = "julm-nix/jj-conflict"; jj-diffconflicts.follows = "julm-nix/jj-diffconflicts"; jj-fugitive.follows = "julm-nix/jj-fugitive"; NicolasGB-jj-nvim.follows = "julm-nix/NicolasGB-jj-nvim"; sivansh11-jj-nvim.follows = "julm-nix/sivansh11-jj-nvim"; }; outputs = inputs: let remoteNixpkgsPatches = import (inputs.julm-nix + "/nixpkgs/patches.nix"); localNixpkgsPatches = [ #nixpkgs/patches/systemd-coredump.diff (inputs.julm-nix + "/nixpkgs/patches/openvpn/openvpn-netns.patch") ( inputs.julm-nix + "/nixpkgs/patches/openvpn/0001-nixos-netns-init-module-to-manage-network-namespaces.patch" ) ]; originPkgs = inputs.nixpkgs.legacyPackages."x86_64-linux"; nixpkgsPath = originPkgs.applyPatches { name = "nixpkgs-patched"; src = inputs.nixpkgs; patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches; postPatch = '' patch=$(printf '%s\n' ${ builtins.concatStringsSep " " (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches) } | sort | sha256sum | cut -c -7) echo "-patch-$patch" >.version-suffix ''; }; profile = "/nix/var/nix/profiles/system"; inherit (inputs.nixpkgs) lib; overlays = args: [ (finalPkgs: previousPkgs: { }) ] ++ import (inputs.julm-nix + "/nixpkgs/overlays.nix") args ++ import nixpkgs/overlays.nix args; #nixosSystem = lib.nixosSystem; nixosSystem = import (nixpkgsPath + "/nixos/lib/eval-config.nix"); forAllSystems = f: lib.genAttrs lib.systems.flakeExposed ( system: f rec { inherit system; #pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = import nixpkgsPath { inherit system; overlays = overlays { inherit inputs system; }; }; } ); in { # nix -L build .#hello packages = forAllSystems (args: with args; pkgs); # nix -L build .#nixosConfigurations.mermet.config.system.build.toplevel # nix -L build .#nixosConfigurations.mermet.config.boot.kernelPackages.kernel.configfile # nix -L build .#nixosConfigurations.mermet.pkgs.hello # nix eval --raw .#nixosConfigurations.mermet.config.networking.nftables.ruleset nixosConfigurations = lib.genAttrs (builtins.attrNames ( lib.filterAttrs (_n: v: v == "directory") (builtins.readDir (inputs.self + "/hosts")) )) ( hostName: nixosSystem { system = null; specialArgs = { # Required to avoid infinite recursion # when `inputs` is used in `imports`. inherit inputs; }; modules = [ nixos/default.nix (inputs.julm-nix + "/nixos/default.nix") (inputs.self + "/hosts/${hostName}.nix") ( { config, ... }: { _module.args = { inherit hostName; hosts = inputs.self.nixosConfigurations; host = inputs.self.nixosConfigurations.${hostName}._module.args; info = import ./info.nix; }; nixpkgs.overlays = overlays { inherit inputs; inherit (config.nixpkgs.hostPlatform) system; }; #nixpkgs.buildPlatform = "x86_64-linux"; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "canon-cups-ufr2" "hplip" ]; } ) inputs.nixpkgs.nixosModules.notDetected inputs.home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.verbose = true; home-manager.backupFileExtension = null; home-manager.extraSpecialArgs = { inherit hostName inputs; }; } { programs.ssh.knownHosts = { carotte = { extraHostNames = [ "carotte" "carotte.sourcephile.fr" ]; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKnnS0w9zm5KuWwlfJu+qEXC0asESQySPp76szyMTE3J"; }; mermet = { extraHostNames = [ "mermet" "mermet.sourcephile.fr" ]; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFvKN2sIpH782MFjaOpcty1Hs/T/TPNJpXI08H3O3oxl"; }; losurdo = { extraHostNames = [ "losurdo" "losurdo.sourcephile.fr" ]; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHJkAq1T0Dxozt4RPylvWrUmeuejiG+n/owb3ucnWP9F"; }; }; } ]; } ); # nix -L develop or direnv allow devShell = forAllSystems ( { pkgs, system, ... }: pkgs.callPackage ./shell.nix { inherit pkgs inputs system nixpkgsPath ; inherit (inputs.self.checks.${system}.git-hooks-check) shellHook; } ); apps = forAllSystems ( { pkgs, system, ... }: builtins.mapAttrs ( hostName: { config, ... }: { # Example: nix run .#mermet.switch "switch" = { type = "app"; program = (pkgs.callPackage (inputs.julm-nix + "/flake/apps/switch.nix") { inherit config hostName nixpkgsPath profile ; inherit (config.system) build; }).outPath; }; } ) inputs.self.nixosConfigurations ); # nix flake check checks = forAllSystems ( args: with args; { git-hooks-check = inputs.git-hooks.lib.${system}.run { src = inputs.self; hooks = { nixfmt-rfc-style.enable = true; }; }; } ); }; }