dotfiles/modules/users/default.nix

113 lines
2.5 KiB
Nix
Raw Normal View History

2024-07-19 12:00:55 +00:00
{
config,
lib,
pkgs,
...
}:
2024-07-18 04:08:27 +00:00
with lib;
let
# Nixvim
2024-09-02 18:03:39 +00:00
nixvim = import (
# builtins.fetchGit {
# url = "https://github.com/nix-community/nixvim";
# # ref = "nixos-24.05";
# }
pkgs.fetchFromGitHub {
owner = "nix-community";
repo = "nixvim";
2024-12-02 10:18:22 +00:00
rev = "e680b367c726e2ae37d541328fe81f8daaf49a6c";
sha256 = "sha256-fYEf0IgsNJp/hcb+C3FKtJvVabPDQs64hdL0izNBwXc=";
2024-09-02 18:03:39 +00:00
}
);
2024-07-18 04:08:27 +00:00
# Stylix
2024-07-19 12:00:55 +00:00
stylix = import (
pkgs.fetchFromGitHub {
owner = "danth";
repo = "stylix";
2024-12-02 10:18:22 +00:00
rev = "5f912cecb4e1c5c794316c4b79b9b5d57d43e100";
sha256 = "sha256-SX1R/WlHEIf9BPT4YBnlVyXRyWNlzYMtKpwXnT9+DPM=";
2024-07-19 12:00:55 +00:00
}
);
2024-07-18 04:08:27 +00:00
# User configuration
userModule = types.submodule {
options = {
sudo = mkOption {
type = types.bool;
default = false;
example = true;
description = "Whether the user is allowed sudo access.";
};
configuration = mkOption {
type = types.path;
default = ./users/base.nix;
description = "What home manager configuration to use for this user.";
};
desktopInit = mkOption {
type = types.lines;
default = "";
description = "Bash script to execute after initial log in.";
};
};
};
2024-07-19 12:00:55 +00:00
in
{
2024-07-18 04:08:27 +00:00
imports = [
# Import home manager
<home-manager/nixos>
# Import system wide configuration required for user modules
2024-07-18 11:48:49 +00:00
./modules/systemwide/default.nix
2024-07-18 04:08:27 +00:00
];
options = {
2025-01-23 23:28:22 +00:00
machine.sudo-groups = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Groups assigned to sudo users.";
};
2024-07-18 04:08:27 +00:00
machine.users = mkOption {
type = types.attrsOf userModule;
2024-07-19 12:00:55 +00:00
default = { };
2024-07-18 04:08:27 +00:00
description = "Users configured on this system.";
};
};
config = {
# Add required home manager modules
home-manager.sharedModules = [
# Stylix for theming
stylix.homeManagerModules.stylix
# Nixvim for neovim
nixvim.homeManagerModules.nixvim
# Modules
./modules/default.nix
2024-07-18 21:36:50 +00:00
# Custom packages
../../pkgs/default.nix
2024-07-18 04:08:27 +00:00
];
# Create users
users.users = attrsets.concatMapAttrs (name: value: {
${name} = {
isNormalUser = true;
2025-01-23 23:28:22 +00:00
extraGroups = mkIf value.sudo (
[
"wheel"
]
++ config.machine.sudo-groups
);
2024-07-18 04:08:27 +00:00
};
}) config.machine.users;
# Create home manager configuration for users
home-manager.users = attrsets.concatMapAttrs (name: value: {
${name} = value.configuration;
}) config.machine.users;
};
}