From 8c946f2d3b36c8e34c1fba4df314f03b74d25a34 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 2 Jan 2021 16:21:34 +0100 Subject: fix user-profiles --- flake.nix | 4 ++-- system-profiles/core.nix | 21 ++++++++++++++++++++- user-profiles/core.nix | 28 +++++----------------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 83f92ac6..52d4026d 100644 --- a/flake.nix +++ b/flake.nix @@ -79,7 +79,7 @@ (inputs: inputs // { inherit userName; }) (outputs: { _file = dir + "/${path}"; } // outputs - // { imports = [self.nixosModules.userProfiles.${userName}.core] ++ (outputs.imports or []); }); + // { imports = defaultUserProfiles userName ++ (outputs.imports or []); }); mkUserProfile = userName: dir: path: profileName: let @@ -102,7 +102,7 @@ (inputs: inputs // { inherit userName; }) (outputs: { _file = dir + "/${path}"; } // outputs - // { imports = defaultUserProfiles userName ++ (outputs.imports or []); }); + // { imports = [self.nixosModules.users.${userName} or ({...}: { imports = defaultUserProfiles userName; })] ++ (outputs.imports or []); }); forAllSystems = f: mapAttrs f nixpkgs.legacyPackages; forAllUsers = genAttrs (unique (map accountUserName (attrNames self.nixosModules.accounts))); diff --git a/system-profiles/core.nix b/system-profiles/core.nix index 79c2fe82..5f2433bb 100644 --- a/system-profiles/core.nix +++ b/system-profiles/core.nix @@ -1,6 +1,8 @@ { flake, flakeInputs, path, hostName, config, lib, pkgs, customUtils, ... }: let profileSet = customUtils.types.attrNameSet flake.nixosModules.systemProfiles; + userProfileSet = customUtils.types.attrNameSet (lib.zipAttrs (lib.attrValues flake.nixosModules.userProfiles)); + hasSops = config.sops.secrets != {}; in { imports = with flakeInputs; [ sops-nix.nixosModules.sops @@ -16,6 +18,18 @@ in { Set (list without duplicates) of ‘systemProfiles’ enabled for this host ''; }; + + users.users = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { + options.profiles = lib.mkOption { + type = userProfileSet; + default = []; + description = '' + Set (list without duplicates) of ‘userProfiles’ enabled for this user + ''; + }; + }); + }; }; config = { @@ -48,6 +62,11 @@ in { # documentation.nixos.includeAllModules = true; # incompatible with home-manager (build fails) - home-manager.useGlobalPkgs = true; # Otherwise home-manager would only work impurely + home-manager = { + useGlobalPkgs = true; # Otherwise home-manager would only work impurely + useUserPackages = true; + }; + + sops.gnupgHome = lib.mkIf hasSops "/root/.gnupg"; }; } diff --git a/user-profiles/core.nix b/user-profiles/core.nix index 6f473b1a..91685611 100644 --- a/user-profiles/core.nix +++ b/user-profiles/core.nix @@ -1,26 +1,8 @@ -{ flake, userName, lib, customUtils, ... }: -let - userProfileSet = customUtils.types.attrNameSet (lib.zipAttrs (lib.attrValues flake.nixosModules.userProfiles)); -in { - options = { - users.users = lib.mkOption { - type = lib.types.attrsOf (lib.types.submodule { - options.profiles = lib.mkOption { - type = userProfileSet; - default = []; - description = '' - Set (list without duplicates) of ‘userProfiles’ enabled for this user - ''; - }; - }); - }; - }; - - config = { - users.users.${userName} = {}; # Just make sure the user is created +{ userName, ... }: +{ + users.users.${userName} = {}; # Just make sure the user is created - home-manager.users.${userName} = { - manual.manpages.enable = true; - }; + home-manager.users.${userName} = { + manual.manpages.enable = true; }; } -- cgit v1.2.3