From 3811e38dac5a1bf814b071313156a8ec2940e509 Mon Sep 17 00:00:00 2001 From: Adam Gausmann Date: Wed, 28 Aug 2024 11:58:09 -0500 Subject: [PATCH] Multi-host Nix framework --- flake.nix | 26 ++++---------------------- justfile | 4 +++- home.nix => modules/common.nix | 0 modules/hosts.nix | 24 ++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 23 deletions(-) rename home.nix => modules/common.nix (100%) create mode 100644 modules/hosts.nix diff --git a/flake.nix b/flake.nix index 3776233..c742974 100644 --- a/flake.nix +++ b/flake.nix @@ -12,26 +12,8 @@ nixGL.url = "github:nix-community/nixGL"; }; - outputs = { nixpkgs, flake-utils, home-manager, nixGL, ... } @ inputs: - flake-utils.lib.eachSystem (with flake-utils.lib.system; [ - x86_64-linux - ]) (system: - let - lib = nixpkgs.lib; - pkgs = import nixpkgs { - inherit system; - overlays = [ nixGL.overlay ]; - }; - in { - packages.homeConfigurations = { - goose = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ ./home.nix ]; - extraSpecialArgs = { - inherit inputs; - }; - }; - }; - } - ); + outputs = { nixpkgs, ... } @ inputs: + (import ./modules/hosts.nix inputs) // { + # TODO devshell config + }; } diff --git a/justfile b/justfile index 5aab52a..cd5f035 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,6 @@ -hm_flags := "--flake .#goose" +user := `whoami` +hostname := `hostname` +hm_flags := "--flake .#" + user + "@" + hostname alias b := build alias inst := install diff --git a/home.nix b/modules/common.nix similarity index 100% rename from home.nix rename to modules/common.nix diff --git a/modules/hosts.nix b/modules/hosts.nix new file mode 100644 index 0000000..2fcfd01 --- /dev/null +++ b/modules/hosts.nix @@ -0,0 +1,24 @@ +{ nixpkgs, flake-utils, home-manager, nixGL, ... } @ inputs: + let + getNixOsPkgs = system: import nixpkgs { inherit system; }; + getPkgs = system: import nixpkgs { + inherit system; + overlays = [ nixGL.overlay ]; + }; + + makeHostSystem = pkgs: modules: home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ ./common.nix ] ++ modules; + extraSpecialArgs = { + inherit inputs; + }; + }; + in + { + packages.x86_64-linux.homeConfigurations = let + pkgs = getPkgs "x86_64-linux"; + makeHost = makeHostSystem pkgs; + in { + "goose@adventurer" = makeHost [ /*./hosts/adventurer.nix*/ ]; + }; + }