1
0
mirror of https://github.com/ellmau/nixos.git synced 2025-12-19 09:29:36 +01:00

Fix home-manager import issue

This commit is contained in:
Stefan Ellmauthaler 2022-05-24 18:02:56 +02:00
parent 8a6fb6c6cc
commit 0793eaa1c3
Failed to extract signature
2 changed files with 116 additions and 106 deletions

101
flake.nix
View File

@ -47,69 +47,74 @@
};
};
outputs = {self, nixpkgs, flake-utils-plus, ...}@inputs:
outputs = { self, nixpkgs, flake-utils-plus, ... }@inputs:
let
extended-lib = nixpkgs.lib.extend
(final: prev: {
elss = (import ./lib {lib = final; }) prev;
elss = (import ./lib { lib = final; }) prev;
});
inherit (extended-lib.elss) discoverModules moduleNames;
in
flake-utils-plus.lib.mkFlake rec{
inherit self inputs;
supportedSystems = [ "x86_64-linux" ];
flake-utils-plus.lib.mkFlake rec{
inherit self inputs;
supportedSystems = [ "x86_64-linux" ];
lib = extended-lib;
lib = extended-lib;
channelsConfig = {
allowUnfreePredicate = pkg: builtins.elem (extended-lib.getName pkg) [
"steam"
"steam-original"
"steam-runtime"
"skypeforlinux"
"teams"
"zoom"
];
};
channels.nixpkgs.overlaysBuilder = channels: [
(final: prev: {
unstable = channels.nixpkgs-unstable;
})
inputs.nix.overlay
inputs.emacs-overlay.overlay
channelsConfig = {
allowUnfreePredicate = pkg: builtins.elem (extended-lib.getName pkg) [
"steam"
"steam-original"
"steam-runtime"
"skypeforlinux"
"teams"
"zoom"
];
};
hostDefaults = {
system = "x86_64-linux";
channelName = "nixpkgs";
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.dwarffs.nixosModules.dwarffs
] ++ (map (name: ./modules + "/${name}") (moduleNames ./modules));
specialArgs = {
nixos-hardware = inputs.nixos-hardware.nixosModules;
inherit inputs;
};
extraArgs = { inherit homeConfigurations; };
channels.nixpkgs.overlaysBuilder = channels: [
(final: prev: {
unstable = channels.nixpkgs-unstable;
})
inputs.nix.overlay
inputs.emacs-overlay.overlay
];
hostDefaults = {
system = "x86_64-linux";
channelName = "nixpkgs";
modules = [
inputs.home-manager.nixosModules.home-manager
inputs.dwarffs.nixosModules.dwarffs
] ++ (map (name: ./modules + "/${name}") (moduleNames ./modules));
specialArgs = {
nixos-hardware = inputs.nixos-hardware.nixosModules;
inherit inputs;
};
extraArgs = {
homeConfigurations = discoverModules ./users
(name:
import (./users + "/${name}")
);
};
};
hosts = discoverModules ./machines (name: {
modules = [ (./machines + "/${name}") ];
specialArgs = { lib = extended-lib; };
});
hosts = discoverModules ./machines (name: {
modules = [ (./machines + "/${name}") ];
specialArgs = { lib = extended-lib; };
});
homeConfigurations = discoverModules ./users
homeConfigurations = discoverModules ./users
(name:
let
username = extended-lib.removeSuffix ".nix" name;
in
inputs.home-manager.lib.homeManagerConfiguration {
configuration = import (./users + "/${name}");
inherit username;
system = "x86_64-linux";
homeDirectory = "/home/${username}";
stateVersion = "21.05";
});
};
inputs.home-manager.lib.homeManagerConfiguration {
configuration = import (./users + "/${name}");
inherit username;
system = "x86_64-linux";
homeDirectory = "/home/${username}";
stateVersion = "21.05";
});
};
}

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, homeConfigurations, ... }:
with lib; {
options.elss.users = {
@ -82,38 +82,38 @@ with lib; {
mkUser = login:
let meta = getMeta login;
in
{
inherit (meta) description;
isNormalUser = true;
home = "/home/${login}";
extraGroups = [ ];
openssh.authorizedKeys.keys = meta.publicKeys;
};
{
inherit (meta) description;
isNormalUser = true;
home = "/home/${login}";
extraGroups = [ ];
openssh.authorizedKeys.keys = meta.publicKeys;
};
mkGitUser = login:
let meta = getMeta login;
in
{
programs.git = {
userEmail = meta.mailAddress;
userName = meta.description;
extraConfig ={
gpg = lib.mkIf meta.git.gpgsm {
format = "x509";
program = "${pkgs.gnupg}/bin/gpgsm";
};
user = {
signingKey = meta.git.key;
signByDefault = meta.git.signDefault;
};
{
programs.git = {
userEmail = meta.mailAddress;
userName = meta.description;
extraConfig = {
gpg = lib.mkIf meta.git.gpgsm {
format = "x509";
program = "${pkgs.gnupg}/bin/gpgsm";
};
user = {
signingKey = meta.git.key;
signByDefault = meta.git.signDefault;
};
};
};
};
mkX11User = login:
let meta = getMeta login;
in
mkIf (cfg.x11.enable)
mkIf (cfg.x11.enable)
{
xsession = {
numlock.enable = true;
@ -133,36 +133,41 @@ with lib; {
};
in
mkIf (cfg.enable)
{
assertions =
let
cfg = config.elss.users;
in
[
{
assertion = mutuallyExclusive cfg.users cfg.admins;
message = "kbs.users.users and kbs.users.admins are mutually exclusive";
}
{
assertion = all (hash: hash != "")
(catAttrs "hashedPassword" (attrVals cfg.admins cfg.meta));
message = "No admin without password";
}
{
assertion = length (cfg.admins) > 0;
message = "One admin needed at least";
}
];
mkIf (cfg.enable)
{
assertions =
let
cfg = config.elss.users;
in
[
{
assertion = mutuallyExclusive cfg.users cfg.admins;
message = "elss.users.users and elss.users.admins are mutually exclusive";
}
{
assertion = all (hash: hash != "")
(catAttrs "hashedPassword" (attrVals cfg.admins cfg.meta));
message = "No admin without password";
}
{
assertion = length (cfg.admins) > 0;
message = "One admin needed at least";
}
];
users = {
mutableUsers = false;
users =
mkMerge [
(mapAdmins mkAdmin)
(mapUsers mkUser)
];
};
home-manager.users = (mapAllUsers mkGitUser) // (mapAllUsers mkX11User) // (mapAllUsersAndRoot (_: { config.home.stateVersion = mkDefault "21.05"; }));
users = {
mutableUsers = false;
users =
mkMerge [
(mapAdmins mkAdmin)
(mapUsers mkUser)
];
};
home-manager.users = mapAllUsersAndRoot (login:
mkMerge [
{ config.home.stateVersion = mkDefault "21.11"; }
(if homeConfigurations ? "${login}" then homeConfigurations."${login}" else { })
]
);
};
}