From 7e7c8947fc2ff5598124c4a4c18bd28432fa017e Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:01:35 -0500 Subject: rework most of config; probably broke jupiter again; working to add ganymede (non-nixos) to this repo --- lib/nix-furnace/default.nix | 102 ----------------------------------------- lib/nix-furnace/mkSystem.nix | 105 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 102 deletions(-) delete mode 100644 lib/nix-furnace/default.nix create mode 100644 lib/nix-furnace/mkSystem.nix (limited to 'lib/nix-furnace') diff --git a/lib/nix-furnace/default.nix b/lib/nix-furnace/default.nix deleted file mode 100644 index 303730e..0000000 --- a/lib/nix-furnace/default.nix +++ /dev/null @@ -1,102 +0,0 @@ -let - my-lib = import ../lib.nix; - inherit (my-lib.globimport) lazyImport getSubdirs getSubfiles; - - mkHomeImports = modName: [ - (lazyImport ../../modules/${modName}/options.nix) - (lazyImport ../../modules/${modName}/home/default.nix) - ]; - mkSystemImports = modName: [ - (lazyImport ../../modules/${modName}/options.nix) - (lazyImport ../../modules/${modName}/system/default.nix) - ]; - - mkModules = mapFn: { - imports = - [../../modules/options.nix] - ++ (builtins.foldl' (a: b: a ++ b) [] (builtins.map mapFn (getSubdirs ../../modules))); - }; - - mkHomeModules = mkModules mkHomeImports; - mkSystemModules = mkModules mkSystemImports; - - mkHost = { - hostname, - namespace, - inputs, - ... - }: let - preloadedConfig = import ../../hosts/${hostname}/config.nix {inherit inputs;}; - username = preloadedConfig."${namespace}".user.name; - - furnaceOptions = {lib, ...}: let - inherit (lib) mkOption types; - in { - options.nix-furnace = { - extraHomeModules = mkOption { - type = with types; listOf path; - default = []; - }; - - extraSystemModules = mkOption { - type = with types; listOf path; - default = []; - }; - }; - }; - - specialArgs = {inherit inputs my-lib;}; - in - inputs.nixpkgs.lib.nixosSystem { - inherit specialArgs; - modules = - [ - {networking.hostName = hostname;} - - ../../hosts/${hostname}/config.nix - - mkSystemModules - - furnaceOptions - - # Home-manager - inputs.home-manager.nixosModules.home-manager - { - home-manager = { - backupFileExtension = "bak"; - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = specialArgs; - users."${username}" = { - imports = - [ - mkHomeModules - - furnaceOptions - - ../../hosts/${hostname}/config.nix - ] - ++ preloadedConfig.nix-furnace.extraHomeModules; - }; - }; - } - ] - ++ preloadedConfig.nix-furnace.extraSystemModules; - }; - - mkFlake = { - namespace, - inputs, - ... - }: { - nixosConfigurations = - builtins.listToAttrs - (builtins.map (hostname: { - name = hostname; - value = mkHost {inherit inputs hostname namespace;}; - }) - (getSubdirs ../../hosts)); - }; -in { - inherit mkFlake; -} diff --git a/lib/nix-furnace/mkSystem.nix b/lib/nix-furnace/mkSystem.nix new file mode 100644 index 0000000..3285f3a --- /dev/null +++ b/lib/nix-furnace/mkSystem.nix @@ -0,0 +1,105 @@ +let + my-lib = import ../lib.nix; + inherit (my-lib.globimport) getSubdirs lazyImport; + + listModules = getSubdirs ../../modules; + + mkNixosSystem = { + inputs, + hostname, + username, + module_types, + }: + inputs.nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs my-lib;}; + modules = [ + {networking.hostName = hostname;} + + ../../hosts/${hostname}/config.nix + + # Nixos-sided modules + { + imports = + [ + ../../modules/options.nix + ../../hosts/${hostname}/config.nix + (lazyImport ../../hosts/${hostname}/nixos.nix) + ] + ++ (listModules + |> (builtins.map (modName: [ + (lazyImport ../../modules/${modName}/options.nix) + (lazyImport ../../modules/${modName}/nixos/default.nix) + ])) + |> my-lib.flatten); + } + + # Home-sided modules + ( + if (builtins.elem "home" module_types) + then { + imports = [ + inputs.home-manager.nixosModules.home-manager + ]; + home-manager = { + backupFileExtension = "bak"; + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = {inherit inputs my-lib;}; + users.${username} = { + imports = + [ + ../../modules/options.nix + ../../hosts/${hostname}/config.nix + (lazyImport ../../hosts/${hostname}/home.nix) + { + home.preferXdgDirectories = true; + } + ] + ++ (listModules + |> (builtins.map (modName: [ + (lazyImport ../../modules/${modName}/options.nix) + (lazyImport ../../modules/${modName}/home/default.nix) + ])) + |> my-lib.flatten); + }; + }; + } + else {} + ) + + # Hjem-sided modules + ( + if (builtins.elem "hjem" module_types) + then { + imports = [ + inputs.hjem.nixosModules.hjem + ]; + hjem = { + extraModules = + [ + ../../modules/options.nix + ../../hosts/${hostname}/config.nix + (lazyImport ../../hosts/${hostname}/hjem.nix) + ] + ++ (listModules + |> (builtins.map (modName: [ + (lazyImport ../../modules/${modName}/options.nix) + (lazyImport ../../modules/${modName}/hjem/default.nix) + ])) + |> my-lib.flatten); + specialArgs = {inherit inputs my-lib;}; + users.${username} = { + enable = true; + user = username; + directory = "/home/${username}"; + }; + }; + } + else {} + ) + + # This is where we would add nix-on-droid modules + ]; + }; +in + mkNixosSystem -- cgit v1.3.1 From 10c22ef344bc22ca62e916d30468e97e368ff99b Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Tue, 9 Sep 2025 20:39:48 -0500 Subject: system-manager for non-nixos machine ganymede --- flake.nix | 17 ++++++++++++++--- hosts/ganymede/system.nix | 8 ++++++++ lib/nix-furnace/mkSystem.nix | 22 ++++++++++++++++++---- 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 hosts/ganymede/system.nix (limited to 'lib/nix-furnace') diff --git a/flake.nix b/flake.nix index 2075adf..05970ce 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,12 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + # for server that doesn't have nixos + system-manager = { + url = "github:numtide/system-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + hjem = { url = "github:feel-co/hjem"; inputs.nixpkgs.follows = "nixpkgs"; @@ -26,19 +32,24 @@ }; outputs = inputs: let - mkSystem = import ./lib/nix-furnace/mkSystem.nix; + inherit (import ./lib/nix-furnace/mkSystem.nix) mkNixosSystem mkSystemManagerSystem; in { - nixosConfigurations."mercury" = mkSystem { + nixosConfigurations."mercury" = mkNixosSystem { inherit inputs; hostname = "mercury"; username = "collin"; module_types = ["hjem" "nixos"]; }; - nixosConfigurations."jupiter" = mkSystem { + nixosConfigurations."jupiter" = mkNixosSystem { inherit inputs; hostname = "jupiter"; username = "collin"; module_types = ["hjem" "home" "nixos"]; }; + + systemConfigs."ganymede" = mkSystemManagerSystem { + inherit inputs; + hostanme = "ganymede"; + }; }; } diff --git a/hosts/ganymede/system.nix b/hosts/ganymede/system.nix new file mode 100644 index 0000000..7eb2e74 --- /dev/null +++ b/hosts/ganymede/system.nix @@ -0,0 +1,8 @@ +{ + config, + lib, + pkgs, + ... +}: { + nixpkgs.hostPlatform = "x86_64-linux"; +} diff --git a/lib/nix-furnace/mkSystem.nix b/lib/nix-furnace/mkSystem.nix index 3285f3a..cf14f4a 100644 --- a/lib/nix-furnace/mkSystem.nix +++ b/lib/nix-furnace/mkSystem.nix @@ -97,9 +97,23 @@ let } else {} ) - - # This is where we would add nix-on-droid modules ]; }; -in - mkNixosSystem + + mkSystemManagerSystem = { + inputs, + hostname, + }: + inputs.system-manager.lib.makeSystemConfig { + modules = + [../../modules/options.nix ../../hosts/${hostname}/system.nix] + ++ (listModules + |> (builtins.map (modName: [ + (lazyImport ../../modules/${modName}/options.nix) + (lazyImport ../../modules/${modName}/system/default.nix) + ])) + |> my-lib.flatten); + }; +in { + inherit mkNixosSystem mkSystemManagerSystem; +} -- cgit v1.3.1