From 154d7b0528f99fd52d85ce6460768678cf9d741c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 13 May 2024 22:17:40 +0100 Subject: [PATCH] refactor for adding new hosts --- flake.nix | 40 ++++++++++++------- home/common/core/default.nix | 5 +++ .../optional/desktop/hyprland/default.nix | 0 .../swww-wallpaper-changer/default.nix | 0 .../common/optional/desktop/waybar.nix | 0 .../common/core => common/optional}/git.nix | 0 home/{sam => }/common/optional/sops.nix | 2 +- home/fileserver.nix | 16 ++++++++ home/{sam => }/nixdev.nix | 6 +++ .../common/core => users/sam}/default.nix | 1 - 10 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 home/common/core/default.nix rename home/{sam => }/common/optional/desktop/hyprland/default.nix (100%) rename home/{sam => }/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix (100%) rename home/{sam => }/common/optional/desktop/waybar.nix (100%) rename home/{sam/common/core => common/optional}/git.nix (100%) rename home/{sam => }/common/optional/sops.nix (92%) create mode 100644 home/fileserver.nix rename home/{sam => }/nixdev.nix (81%) rename home/{sam/common/core => users/sam}/default.nix (99%) diff --git a/flake.nix b/flake.nix index 21a306b..f16a832 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,7 @@ # This is a function that generates an attribute by calling a function you # pass to it, with each system as an argument forAllSystems = nixpkgs.lib.genAttrs systems; + specialArgs = { inherit inputs outputs; }; in { # Your custom packages # Accessible through 'nix build', 'nix shell', etc @@ -60,26 +61,37 @@ nixosConfigurations = { # FIXME replace with your hostname nixdev = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs;}; + inherit specialArgs; modules = [ # > Our main nixos configuration file < ./hosts/nixdev + home-manager.nixosModules.home-manager{ + home-manager.extraSpecialArgs = specialArgs; + } ]; }; }; - # Standalone home-manager configuration entrypoint - # Available through 'home-manager --flake .#your-username@your-hostname' - homeConfigurations = { - # FIXME replace with your username@hostname - "sam@nixdev" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = {inherit inputs outputs ;}; - modules = [ - # > Our main home-manager configuration file < - ./home/sam/nixdev.nix - ]; - }; - }; +# # Standalone home-manager configuration entrypoint +# # Available through 'home-manager --flake .#your-username@your-hostname' +# homeConfigurations = { +# # FIXME replace with your username@hostname +# "sam@nixdev" = home-manager.lib.homeManagerConfiguration { +# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance +# extraSpecialArgs = {inherit inputs outputs ;}; +# modules = [ +# # > Our main home-manager configuration file < +# ./home/nixdev.nix +# ]; +# }; +# "admin@fileserver" = home-manager.lib.homeManagerConfiguration { +# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance +# extraSpecialArgs = {inherit inputs outputs ;}; +# modules = [ +# # > Our main home-manager configuration file < +# ./home/nixdev.nix +# ]; +# }; +# }; }; } diff --git a/home/common/core/default.nix b/home/common/core/default.nix new file mode 100644 index 0000000..2645f98 --- /dev/null +++ b/home/common/core/default.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: +{ + imports = [ + ] ; +} diff --git a/home/sam/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix similarity index 100% rename from home/sam/common/optional/desktop/hyprland/default.nix rename to home/common/optional/desktop/hyprland/default.nix diff --git a/home/sam/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix b/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix similarity index 100% rename from home/sam/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix rename to home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix diff --git a/home/sam/common/optional/desktop/waybar.nix b/home/common/optional/desktop/waybar.nix similarity index 100% rename from home/sam/common/optional/desktop/waybar.nix rename to home/common/optional/desktop/waybar.nix diff --git a/home/sam/common/core/git.nix b/home/common/optional/git.nix similarity index 100% rename from home/sam/common/core/git.nix rename to home/common/optional/git.nix diff --git a/home/sam/common/optional/sops.nix b/home/common/optional/sops.nix similarity index 92% rename from home/sam/common/optional/sops.nix rename to home/common/optional/sops.nix index a86f8da..040a808 100644 --- a/home/sam/common/optional/sops.nix +++ b/home/common/optional/sops.nix @@ -1,6 +1,6 @@ { inputs, config, ... }: let - secretsFile = ../../../../secrets.yaml; + secretsFile = ../../../secrets.yaml; homeDirectory = config.home.homeDirectory; in { diff --git a/home/fileserver.nix b/home/fileserver.nix new file mode 100644 index 0000000..436f780 --- /dev/null +++ b/home/fileserver.nix @@ -0,0 +1,16 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./common/core + ./common/optional/sops.nix + + # Import optional + ./common/optional/git.nix + + # Import users + ./users/admin + ]; diff --git a/home/sam/nixdev.nix b/home/nixdev.nix similarity index 81% rename from home/sam/nixdev.nix rename to home/nixdev.nix index dba953b..945b98b 100644 --- a/home/sam/nixdev.nix +++ b/home/nixdev.nix @@ -9,6 +9,12 @@ ./common/optional/desktop/hyprland ./common/optional/desktop/waybar.nix ./common/optional/sops.nix + + # Import optional + ./common/optional/git.nix + + # Import users + ./users/sam ]; # ------ diff --git a/home/sam/common/core/default.nix b/home/users/sam/default.nix similarity index 99% rename from home/sam/common/core/default.nix rename to home/users/sam/default.nix index 3450e44..9692643 100644 --- a/home/sam/common/core/default.nix +++ b/home/users/sam/default.nix @@ -6,7 +6,6 @@ home.stateVersion = "23.11"; imports = [ - ./git.nix ] ++ (builtins.attrValues outputs.homeManagerModules); # import all homeManagerModules? home.packages = [