diff --git a/flake.nix b/flake.nix index 3e38d30..2638973 100644 --- a/flake.nix +++ b/flake.nix @@ -16,10 +16,6 @@ outputs = { self, home-manager, nixpkgs, nixvim, sops-nix, ...}: let - allowed-unfree-packages = [ - "corefonts" - "mongodb" - ]; configFiles = pkgs.stdenv.mkDerivation { name = "config-files"; src = ./configs; @@ -32,110 +28,32 @@ system = "x86_64-linux"; in { nixosConfigurations = { - corp = nixpkgs.lib.nixosSystem { - modules = [ - home-manager.nixosModules.home-manager - { - home-manager.extraSpecialArgs = { inherit configFiles; }; - home-manager.sharedModules = [ - nixvim.homeManagerModules.nixvim - ./modules/home/nixvim.nix - ]; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - } - ./host/corp/configuration.nix - ./modules - sops-nix.nixosModules.sops { - sops = { - age.generateKey = true; - age.keyFile = "/var/libs/sops-nix/key.txt"; - age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = ./secrets/secrets.yaml; - }; - } - ./users - ]; - pkgs = import nixpkgs { - config = { - allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) allowed-unfree-packages; - }; - system = "${system}"; - }; - specialArgs = { - inherit configFiles; - }; - system = "${system}"; + corp = import ./system.nix { + configuration = ./host/corp/configuration.nix; + inherit configFiles; + inherit home-manager; + inherit nixpkgs; + inherit nixvim; + inherit sops-nix; + inherit system; }; - "sync.nidus.cloud" = nixpkgs.lib.nixosSystem { - modules = [ - home-manager.nixosModules.home-manager - { - home-manager.extraSpecialArgs = { inherit configFiles; }; - home-manager.sharedModules = [ - nixvim.homeManagerModules.nixvim - ./modules/home/nixvim.nix - ]; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - } - ./host/sync/configuration.nix - ./modules - sops-nix.nixosModules.sops { - sops = { - age.generateKey = true; - age.keyFile = "/var/libs/sops-nix/key.txt"; - age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = ./secrets/secrets.yaml; - }; - } - ./users - ]; - pkgs = import nixpkgs { - config = { - allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) allowed-unfree-packages; - }; - system = "${system}"; - }; - specialArgs = { - inherit configFiles; - }; - system = "${system}"; + "sync.nidus.cloud" = import ./system.nix { + configuration = ./host/sync/configuration.nix; + inherit configFiles; + inherit home-manager; + inherit nixpkgs; + inherit nixvim; + inherit sops-nix; + inherit system; }; test-corp = nixpkgs.lib.nixosSystem { - modules = [ - home-manager.nixosModules.home-manager - { - home-manager.extraSpecialArgs = { inherit configFiles; }; - home-manager.sharedModules = [ - nixvim.homeManagerModules.nixvim - ./modules/home/nixvim.nix - ]; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - } - ./host/test-corp/configuration.nix - ./modules - sops-nix.nixosModules.sops { - sops = { - age.generateKey = true; - age.keyFile = "/var/libs/sops-nix/key.txt"; - age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - defaultSopsFile = ./secrets/secrets.yaml; - }; - } - ./users - ]; - pkgs = import nixpkgs { - config = { - allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) allowed-unfree-packages; - }; - system = "${system}"; - }; - specialArgs = { - inherit configFiles; - }; - system = "${system}"; + configuration = ./host/test-corp/configuration.nix; + inherit configFiles; + inherit home-manager; + inherit nixpkgs; + inherit nixvim; + inherit sops-nix; + inherit system; }; }; }; diff --git a/system.nix b/system.nix new file mode 100644 index 0000000..3cc571d --- /dev/null +++ b/system.nix @@ -0,0 +1,41 @@ +{ configFiles, configuration, home-manager, nixpkgs, nixvim, sops-nix, system, ... }: +let + allowed-unfree-packages = [ + "corefonts" + "mongodb" + ]; +in nixpkgs.lib.nixosSystem { + modules = [ + home-manager.nixosModules.home-manager + { + home-manager.extraSpecialArgs = { inherit configFiles; }; + home-manager.sharedModules = [ + nixvim.homeManagerModules.nixvim + ./modules/home/nixvim.nix + ]; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + } + configuration + ./modules + sops-nix.nixosModules.sops { + sops = { + age.generateKey = true; + age.keyFile = "/var/libs/sops-nix/key.txt"; + age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + defaultSopsFile = ./secrets/secrets.yaml; + }; + } + ./users + ]; + pkgs = import nixpkgs { + config = { + allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) allowed-unfree-packages; + }; + system = "${system}"; + }; + specialArgs = { + inherit configFiles; + }; + system = "${system}"; +}