Merge remote-tracking branch 'origin/home_manager' into uconsole-cm5-incremental
# Conflicts: # flake.lock # flake.nix # modules/nixos/services/default.nix
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
|||||||
[submodule "assets/compose"]
|
[submodule "assets/compose"]
|
||||||
path = assets/compose
|
path = assets/compose
|
||||||
url = ssh://git@code.lazyworkhorse.net:2222/gortium/compose.git
|
url = ssh://git@code.lazyworkhorse.net:2222/gortium/compose.git
|
||||||
|
[submodule "assets/dotfiles"]
|
||||||
|
path = assets/dotfiles
|
||||||
|
url = ssh://git@code.lazyworkhorse.net:2222/gortium/dotfiles.git
|
||||||
|
|||||||
6
modules/nixos/services/default.nix
Normal file
6
modules/nixos/services/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./dotfiles.nix
|
||||||
|
./systemd
|
||||||
|
];
|
||||||
|
}
|
||||||
69
modules/nixos/services/dotfiles.nix
Normal file
69
modules/nixos/services/dotfiles.nix
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.dotfiles;
|
||||||
|
stowDir = cfg.stowDir;
|
||||||
|
|
||||||
|
# Function to recursively find all files in a directory
|
||||||
|
findFiles = dir:
|
||||||
|
let
|
||||||
|
files = builtins.attrNames (builtins.readDir dir);
|
||||||
|
in
|
||||||
|
concatMap (name:
|
||||||
|
let
|
||||||
|
path = dir + "/${name}";
|
||||||
|
in
|
||||||
|
if (builtins.typeOf (builtins.readDir path) == "set")
|
||||||
|
then findFiles path
|
||||||
|
else [ path ]
|
||||||
|
) files;
|
||||||
|
|
||||||
|
# Get a list of all packages (directories) in the stow directory
|
||||||
|
stowPackages = builtins.attrNames (builtins.readDir stowDir);
|
||||||
|
|
||||||
|
# Create an attribute set where each attribute is a package name
|
||||||
|
# and the value is a list of files to be linked.
|
||||||
|
homeManagerLinks = listToAttrs (map (pkg:
|
||||||
|
let
|
||||||
|
pkgPath = stowDir + "/${pkg}";
|
||||||
|
files = findFiles pkgPath;
|
||||||
|
in
|
||||||
|
nameValuePair pkg (map (file: {
|
||||||
|
source = file;
|
||||||
|
target = removePrefix (pkgPath + "/") file;
|
||||||
|
}) files)
|
||||||
|
) stowPackages);
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.dotfiles = {
|
||||||
|
enable = mkEnableOption "Enable dotfiles management";
|
||||||
|
|
||||||
|
stowDir = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
description = "The directory where your stow packages are located.";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The user to manage dotfiles for.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home-manager.users.${cfg.user} = {
|
||||||
|
home.file =
|
||||||
|
let
|
||||||
|
allFiles = concatLists (attrValues homeManagerLinks);
|
||||||
|
in
|
||||||
|
listToAttrs (map (file:
|
||||||
|
nameValuePair file.target {
|
||||||
|
source = file.source;
|
||||||
|
}
|
||||||
|
) allFiles);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{ pkgs, inputs, config, keys, ... }: {
|
{ pkgs, inputs, config, keys, ... }: {
|
||||||
|
home-manager.users.gortium = import ./home.nix;
|
||||||
users.users.gortium = {
|
users.users.gortium = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" "docker" "video" "render"];
|
extraGroups = [ "wheel" "docker" "video" "render"];
|
||||||
12
users/gortium/home.nix
Normal file
12
users/gortium/home.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
services.dotfiles = {
|
||||||
|
enable = true;
|
||||||
|
stowDir = ../../../assets/dotfiles;
|
||||||
|
user = "gortium";
|
||||||
|
};
|
||||||
|
|
||||||
|
home.username = "gortium";
|
||||||
|
home.homeDirectory = "/home/gortium";
|
||||||
|
home.stateVersion = "23.11"; # Please change this to your version.
|
||||||
|
programs.home-manager.enable = true;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user