From c0dda38da1b8dce75313b61b604e50dcd846f375 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Sun, 9 Feb 2025 18:31:07 +0100 Subject: [PATCH] treewide: export shared/modules/hjem This method takes inspiration from how [hjem-rum](https://github.com/snugnug/hjem-rum) does it --- flake.nix | 5 +++-- hosts/default.nix | 8 ++++++-- modules/core/users.nix | 12 +++++------- shared/modules/hjem/{ => collection}/environment.nix | 0 shared/modules/hjem/nixos.nix | 11 +++++++++++ 5 files changed, 25 insertions(+), 11 deletions(-) rename shared/modules/hjem/{ => collection}/environment.nix (100%) create mode 100644 shared/modules/hjem/nixos.nix diff --git a/flake.nix b/flake.nix index 563d992..4198535 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,8 @@ (system: function nixpkgs.legacyPackages.${system}); treefmtEval = forAllSystems (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); in { + checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; + deploy.nodes = import ./nodes.nix {inherit inputs;}; devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = [ @@ -29,9 +31,8 @@ }); formatter = forAllSystems (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); nixosConfigurations = import ./hosts {inherit self inputs;}; + nixosModules.hjemModules = import ./shared/modules/hjem/nixos.nix {inherit (nixpkgs) lib;}; packages = forAllSystems (pkgs: import ./shared/pkgs {inherit inputs pkgs;}); - deploy.nodes = import ./nodes.nix {inherit inputs;}; - checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; }; inputs = { # nix related diff --git a/hosts/default.nix b/hosts/default.nix index 24ebd3b..d965e3d 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,8 +1,12 @@ -{inputs, ...}: let +{ + self, + inputs, + ... +}: let lib' = import ../lib inputs.nixpkgs.lib; mkSystem = args: inputs.nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs lib';}; + specialArgs = {inherit self inputs lib';}; modules = (args.modules or []) ++ [../modules]; diff --git a/modules/core/users.nix b/modules/core/users.nix index 413c172..c3aa23a 100644 --- a/modules/core/users.nix +++ b/modules/core/users.nix @@ -1,17 +1,19 @@ { + self, inputs, lib, config, ... }: let inherit (lib.modules) mkIf; - inherit (lib.lists) singleton; - inherit (lib.filesystem) listFilesRecursive; inherit (config.local.systemVars) username; inherit (config.local.homeVars) fullName; inherit (config.local.profiles) desktop; in { - imports = [inputs.hjem.nixosModules.default]; + imports = [ + inputs.hjem.nixosModules.default + self.outputs.nixosModules.hjemModules + ]; users.users.${username} = { isNormalUser = true; description = fullName; @@ -31,9 +33,5 @@ in { directory = "/home/${username}"; user = "${username}"; }; - - extraModules = singleton { - imports = listFilesRecursive ../../shared/modules/hjem; - }; }; } diff --git a/shared/modules/hjem/environment.nix b/shared/modules/hjem/collection/environment.nix similarity index 100% rename from shared/modules/hjem/environment.nix rename to shared/modules/hjem/collection/environment.nix diff --git a/shared/modules/hjem/nixos.nix b/shared/modules/hjem/nixos.nix new file mode 100644 index 0000000..6b2aa5b --- /dev/null +++ b/shared/modules/hjem/nixos.nix @@ -0,0 +1,11 @@ +{lib}: let + inherit (lib.filesystem) listFilesRecursive; +in { + config = { + hjem.extraModules = [ + { + imports = listFilesRecursive ./collection; + } + ]; + }; +}