From d80551ebb84d401e7c7e37d3b4157104c5835745 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani <54818348+kiana-S@users.noreply.github.com> Date: Tue, 11 Jan 2022 13:01:08 -0500 Subject: [PATCH] Refactor flake.nix --- flake.nix | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/flake.nix b/flake.nix index 554a9f1..63e51c0 100644 --- a/flake.nix +++ b/flake.nix @@ -17,38 +17,29 @@ outputs = { self, username = "kiana"; moduleArgs = inputs // { inherit system username; }; lib = nixpkgs.lib; + + modulesFor = system: + [ + { _module.args = moduleArgs; } + ./common/config + ./${system}/config + home-manager.nixosModules.home-manager + { home-manager = { + useGlobalPkgs = true; + users.${username} = import ./${system}/home-manager; + extraSpecialArgs = moduleArgs; + }; } + ]; in { nixosConfigurations = { "kiana-desktop" = lib.makeOverridable lib.nixosSystem { inherit system; - modules = [ - { _module.args = moduleArgs; } - ./common/config - ./desktop/config - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.${username} = import ./desktop/home-manager; - home-manager.extraSpecialArgs = moduleArgs; - } - ]; + modules = modulesFor "desktop"; }; "kiana-laptop" = lib.makeOverridable lib.nixosSystem { inherit system; - modules = [ - { _module.args = moduleArgs; } - ./common/config - ./laptop/config - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.${username} = import ./laptop/home-manager; - home-manager.extraSpecialArgs = moduleArgs; - } - ]; + modules = modulesFor "laptop"; }; }; };