diff --git a/flake.nix b/flake.nix index 27c0ff7..7de2980 100644 --- a/flake.nix +++ b/flake.nix @@ -16,39 +16,34 @@ let system = "x86_64-linux"; homeManagerConfFor = config: { ... }: { - #nixpkgs.overlays = [ nur.overlay ]; - imports = [ config ]; - }; + #nixpkgs.overlays = [ nur.overlay ]; + imports = [ config ]; + }; + mkNixosSystem = extraModules: nixpkgs.lib.nixosSystem { + inherit system; + # see https://dataswamp.org/~solene/2022-07-20-nixos-flakes-command-sync-with-system.html + specialArgs = { inherit inputs; }; + modules = [ + home-manager.nixosModules.home-manager { + home-manager.useUserPackages = true; + home-manager.users.jacob = homeManagerConfFor ./home/jacob.nix; + } + sops-nix.nixosModules.sops + ] ++ extraModules; + }; in { - nixosConfigurations = { # Thinkpad T470 laptop - buck = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - nixos-hardware.nixosModules.lenovo-thinkpad-t470s - ./machines/buck/configuration.nix - home-manager.nixosModules.home-manager { - home-manager.useUserPackages = true; - home-manager.users.jacob = homeManagerConfFor ./home/jacob.nix; - } - sops-nix.nixosModules.sops - ]; - }; + buck = mkNixosSystem [ + nixos-hardware.nixosModules.lenovo-thinkpad-t470s + ./machines/buck/configuration.nix + ]; # ThinkCentre M700 mini-pc (server) - pedro = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - nixos-hardware.nixosModules.common-pc-hdd - nixos-hardware.nixosModules.common-cpu-intel-cpu-only - ./machines/pedro/configuration.nix - home-manager.nixosModules.home-manager { - home-manager.useUserPackages = true; - home-manager.users.jacob = homeManagerConfFor ./home/jacob.nix; - } - sops-nix.nixosModules.sops - ]; - }; + pedro = mkNixosSystem [ + nixos-hardware.nixosModules.common-pc-hdd + nixos-hardware.nixosModules.common-cpu-intel-cpu-only + ./machines/pedro/configuration.nix + ]; }; }; } diff --git a/machines/pedro/configuration.nix b/machines/pedro/configuration.nix index bf27a46..f7e30f7 100644 --- a/machines/pedro/configuration.nix +++ b/machines/pedro/configuration.nix @@ -1,12 +1,18 @@ # Edit this configuration file to define what should be installed on your system. Help is available in the configuration.nix(5) man page and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, options, sops, ... }: +{ config, pkgs, inputs, options, sops, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration-zfs.nix ]; + # This lets us pin the nixpkgs registry by default to the nixpkgs used to build this system. + # Doing this means we are less likely to require the 30+MB download when + # running commands like nix search or nix run + # See: https://dataswamp.org/~solene/2022-07-20-nixos-flakes-command-sync-with-system.html + nix.registry.nixpkgs.flake = inputs.nixpkgs; + sops = { # This will add secrets.yml to the nix store # You can avoid this by adding a string to the full path instead, i.e.