From 8f0ca00343c847285f6c9c7b1887e595ec313004 Mon Sep 17 00:00:00 2001 From: Joshua Yuen Date: Fri, 11 Sep 2026 22:55:03 -0400 Subject: [PATCH] Simplify flake.nix --- flake.nix | 102 ++++++++++++++++++++---------------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/flake.nix b/flake.nix index 1b1a4c2..314df8b 100644 --- a/flake.nix +++ b/flake.nix @@ -47,98 +47,72 @@ }@inputs: let system = "x86_64-linux"; + username = "josh"; + profile = "desktop"; + homePath = ./. + "/homes/${username}/home.nix"; + pkgs = import nixpkgs { inherit system; config.allowUnfree = true; overlays = [ nix-vscode-extensions.overlays.default ]; }; + + mkHost = + { + host, + extraModules ? [ ], + }: + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { + inherit + homePath + host + inputs + profile + username + ; + }; + inherit pkgs; + modules = [ ./hosts/${host} ] ++ extraModules; + }; in { nixosConfigurations = { - laptop = let - host = "laptop"; - profile = "desktop"; - username = "josh"; - in nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit host; - inherit profile; - inherit username; - }; - pkgs = pkgs; - modules = [ - ./hosts/${host} - ]; - }; + laptop = mkHost { host = "laptop"; }; - vm = let - host = "vm"; - profile = "desktop"; - username = "josh"; - in nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit host; - inherit profile; - inherit username; - }; - pkgs = pkgs; - modules = [ - ./hosts/${host} - ]; - }; + vm = mkHost { host = "vm"; }; - live = let + live = mkHost { host = "installation-iso"; - profile = "desktop"; - username = "josh"; - in nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { - inherit inputs; - inherit host; - inherit profile; - inherit username; - }; - pkgs = pkgs; - modules = [ + extraModules = [ (nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix") { environment.systemPackages = [ install-system.packages.${system}.default ]; } - ./hosts/installation-iso ]; }; }; - homeConfigurations.josh = let - profile = "desktop"; - username = "josh"; - gpgSigningKey = null; - in home-manager.lib.homeManagerConfiguration { - extraSpecialArgs = { - inherit inputs; - inherit profile; - inherit username; - }; - pkgs = pkgs; + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + extraSpecialArgs = { + inherit inputs profile username; + }; + inherit pkgs; modules = [ { - modules.gpg.signingKey = gpgSigningKey; + modules.gpg.signingKey = null; } - ./homes/josh/home.nix + homePath stylix.homeModules.stylix ]; }; - devShell.${system} = nixpkgs.legacyPackages.${system}.pkgs.mkShell { - packages = with nixpkgs.legacyPackages.${system}.pkgs; [ + devShell.${system} = pkgs.mkShell { + packages = with pkgs; [ nil nixd ]; }; - formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-tree; + formatter.${system} = pkgs.nixfmt-tree; }; }