summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/default.nix2
-rw-r--r--util/host.nix12
-rw-r--r--util/user.nix97
3 files changed, 78 insertions, 33 deletions
diff --git a/util/default.nix b/util/default.nix
index 2d42909..0fb91b5 100644
--- a/util/default.nix
+++ b/util/default.nix
@@ -1,4 +1,4 @@
{home-manager, ...}: {
- host = import ./host.nix {inherit home-manager;};
+ host = import ./host.nix {};
user = import ./user.nix {inherit home-manager;};
}
diff --git a/util/host.nix b/util/host.nix
index da2c692..2c7906c 100644
--- a/util/host.nix
+++ b/util/host.nix
@@ -1,4 +1,4 @@
-{home-manager, ...}: {
+_: {
mkHost = {
name,
modules,
@@ -18,6 +18,7 @@
({pkgs, ...}: {
system.stateVersion = version;
networking.hostName = mkDefault name;
+
# enable non-free packages
nixpkgs.config = {
allowUnfree = true;
@@ -30,15 +31,6 @@
settings.experimental-features = ["nix-command" "flakes"];
};
})
-
- home-manager.nixosModules.home-manager
- {
- home-manager = {
- useGlobalPkgs = true;
- useUserPackages = true;
- extraSpecialArgs = specialArgs;
- };
- }
]
++ modules;
};
diff --git a/util/user.nix b/util/user.nix
index 366112f..3953f11 100644
--- a/util/user.nix
+++ b/util/user.nix
@@ -1,10 +1,22 @@
-{home-manager, ...}: {
+{home-manager, ...}: let
+ commonHM = {
+ nixpkgs.config = {
+ allowUnfree = true;
+ allowUnsupportedSystem = true;
+ };
+ xdg.configFile."nixpkgs/config.nix".text = ''
+ {
+ allowUnfree = true;
+ }
+ '';
+ };
+in {
mkHMUser = {
username,
- stateVersion ? "22.11",
- system ? "x86_64-linux",
channel,
modules ? [],
+ stateVersion ? "22.11",
+ system ? "x86_64-linux",
extraSpecialArgs ? {},
}:
home-manager.lib.homeManagerConfiguration {
@@ -13,27 +25,68 @@
modules =
[
../users/${username}/home.nix
- {
- nixpkgs.config = {
- allowUnfree = true;
- allowUnsupportedSystem = true;
- };
-
- nix = {
- package = channel.legacyPackages.${system}.nixFlakes;
- settings.experimental-features = ["nix-command" "flakes"];
- };
+ ({pkgs, ...}:
+ {
+ home = {
+ inherit username stateVersion;
+ homeDirectory = "/home/${username}";
+ };
- systemd.user.startServices = true;
-
- home = {
- inherit username stateVersion;
- homeDirectory = "/home/${username}";
- };
-
- programs.home-manager.enable = true;
- }
+ programs.home-manager.enable = true;
+ nix = {
+ package = pkgs.nixFlakes;
+ settings.experimental-features = ["nix-command" "flakes"];
+ };
+ }
+ // commonHM)
]
++ modules;
};
+ mkUser = {
+ username,
+ extraGroups ? [],
+ extraModules ? [],
+ extraSpecialArgs ? {},
+ hashedPassword,
+ hm ? false,
+ shell,
+ stateVersion,
+ system ? "x86_64-linux",
+ }:
+ [
+ {
+ users.users.${username} = {
+ inherit extraGroups hashedPassword shell;
+ isNormalUser = true;
+ };
+ }
+ ]
+ ++ extraModules
+ ++ (
+ if hm
+ then [
+ home-manager.nixosModules.home-manager
+ {
+ home-manager = {
+ inherit extraSpecialArgs;
+ useGlobalPkgs = true;
+ useUserPackages = true;
+ users.${username} =
+ {
+ imports = [
+ ../users/${username}/home.nix
+ ];
+ home.stateVersion = stateVersion;
+ }
+ // commonHM
+ // (
+ if builtins.match ".*-linux" system != null
+ then {systemd.user.startServices = true;}
+ else {}
+ );
+ };
+ }
+ ]
+ else []
+ );
}