refactor of user

This commit is contained in:
ari committed 2024-08-09 13:20:30 -04:00
1 parent a81a8ac57b
commit e7d22b40ff
9 files changed
+75 -199

No files matched your search

+34 -50
View File
@@ -62,25 +62,6 @@
];
};
localDockerRegistries = [ "minipc1.lab.internal:5001" ];
# Libs
lib = (import modules/lib.nix {
nixpkgs = nixpkgs;
home-manager = home-manager;
nix-darwin = nix-darwin;
lix-module = lix-module;
});
unstableLib = (import modules/lib.nix {
nixpkgs = unstable;
home-manager = unstable-home-manager;
nix-darwin = nix-darwin;
lix-module = lix-module;
});
eachSystem = nixpkgs.lib.genAttrs (import systems);
unstablePkgs = eachSystem (system:
import unstable {
system = system;
config = { allowUnfree = true; };
});
hlCommonSettings = {
system = "x86_64-linux";
user = user;
@@ -104,39 +85,42 @@
};
};
};
makeHLService = lib.makeNixOsModuleMaker hlCommonSettings;
makeunstableHLService = unstableLib.makeNixOsModuleMaker hlCommonSettings;
homeLabModulesUsingStable = builtins.map
(name: {
name = name;
value = makeHLService {
hostName = name;
configuration = (import (./hosts + "/${name}.nix") { user = user; });
systemStateVersion = "24.05";
};
# Lib Config
libConfig = {
nix-darwin = nix-darwin;
lix-module = lix-module;
hlCommonSettings = hlCommonSettings;
systems = systems;
};
# Libs
lib = (import modules/lib.nix ({
nixpkgs = nixpkgs;
home-manager = home-manager;
} // libConfig));
unstableLib = (import modules/lib.nix ({
nixpkgs = unstable;
home-manager = unstable-home-manager;
} // libConfig));
homelabServices = (
(lib.makeHLServices {
user = user;
nodeNames = [
"hl-minipc1"
"hl-minipc2"
"hl-terra1"
];
}) // (unstableLib.makeHLServices {
user = user;
nodeNames = [
"hl-bigbox1"
];
})
([
"hl-minipc1"
"hl-minipc2"
"hl-terra1"
]);
homeLabModulesUsingUnStable = builtins.map
(name: {
name = name;
value = makeunstableHLService {
hostName = name;
configuration = (import (./hosts + "/${name}.nix") { user = user; });
systemStateVersion = "24.05";
};
})
([
"hl-bigbox1"
]);
);
in
{
lib = lib;
formatter =
eachSystem (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
lib.eachSystem (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
# MacBooks Setups
# -------------
@@ -197,14 +181,14 @@
nixos-hardware.nixosModules.framework-13-7040-amd
(import ./hosts/fwbook.nix {
user = user;
unstable = unstablePkgs.x86_64-linux;
unstable = unstableLib.pkgs.x86_64-linux;
})
];
};
};
# NIXOS Framework Homelab
# -------------
hl-fws1 = makeHLService {
hl-fws1 = lib.makeHLService {
hostName = "hl-fws1";
configuration = { ... }: {
imports = [
@@ -214,6 +198,6 @@
};
systemStateVersion = "24.05";
};
} // (builtins.listToAttrs homeLabModulesUsingStable) // (builtins.listToAttrs homeLabModulesUsingUnStable);
} // homelabServices;
};
}
+1
View File
@@ -121,4 +121,5 @@ in
'';
};
systemd.sleep.extraConfig = "HibernateDelaySec=30m";
skyg.core.hostName = "fwbook";
}
+1 -77
View File
@@ -1,17 +1,11 @@
{ hostName, version, user, enableDevelopmentKit ? false, ... }:
{ pkgs, ... }:
let
gitconfigs =
(builtins.filterSource (path: type: type != "directory") ./gitconfigs);
gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs);
in
{
home-manager.users.root = {
home.stateVersion = version;
programs.git = {
enable = true;
userName = "root";
userEmail = "root@${hostName}";
};
programs.zsh = {
enable = true;
@@ -19,75 +13,5 @@ in
};
programs.zsh.oh-my-zsh.enable = true;
};
home-manager.users.${user.name} = {
home = {
sessionVariables = { };
stateVersion = version;
shellAliases = {
cat = "bat";
};
packages = with pkgs;
[ jq nixfmt-classic devenv ipfetch nixd ]
++ (if enableDevelopmentKit then [
rye
uv
devbox
terraform
kubectl
] else
[ ]);
};
programs = {
bat.enable = true;
neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
};
direnv.enable = true;
lsd = {
enable = true;
enableAliases = true;
};
git = {
enable = true;
userName = user.fullName;
userEmail = user.email;
delta = { enable = true; };
extraConfig = {
color = { ui = "auto"; };
push = {
default = "upstream";
autoSetupRemote = true;
};
init = { defaultBranch = "main"; };
};
includes =
(builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles)
++ (if builtins.hasAttr "extraGitConfigs" user then
user.extraGitConfigs
else
[ ]);
};
zsh = {
enable = true;
autosuggestion.enable = true;
initExtra = ''
export PROMPT='%(!.%{%F{yellow}%}.)$USER@%{$fg[white]%}%M %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
'';
};
zsh.oh-my-zsh = {
enable = true;
plugins = [ "git" "sudo" ];
theme = "robbyrussell";
};
tmux = {
enable = true;
clock24 = true;
mouse = true;
plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ];
};
};
};
}
-21
View File
@@ -1,21 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.skyg.home-manager.gitaliases;
gitconfigs =
(builtins.filterSource (path: type: type != "directory") ./gitconfigs);
gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs);
in
{
options = {
skyg.home-manager.gitaliases = {
enable = mkEnableOption
"Use my awesome git aliases";
};
};
config = mkIf cfg.enable { };
}
@@ -1,32 +0,0 @@
[alias]
pp = "!f() { \
echo 'git pull --ff';\
git pull --ff; \
echo 'git push';\
git push; \
}; f";
up = "pull --rebase --autostash";
ca = "commit -a";
ls = "log --oneline";
cap = "!f() { \
echo 'commiting code'; \
git ca ${@}; \
echo 'pushing...'; \
git push ; \
}; f";
undo-commit = "!f() { \
lastcommit=$(git log --oneline -n 1); \
echo '[[switching]] from' $lastcommit; \
git reset --soft HEAD~${1:-1}; \
lastcommit=$(git log --oneline -n 1); \
echo '[[switching]] to' $lastcommit; \
git status; \
}; f";
sync = "!f() { \
target_branch=${1:-main}; \
remote=${2:-origin}; \
git fetch $remote $target_branch:$target_branch; \
}; f";
clean-branches = "!f() { \
git for-each-ref --format '%(refname:short)' refs/heads| grep -v 'master\\|main' | xargs git branch -D ; \
}; f";
+35 -15
View File
@@ -2,6 +2,8 @@
, home-manager
, nix-darwin
, lix-module
, systems
, hlCommonSettings
}:
let
makeImports =
@@ -15,34 +17,31 @@ let
home-manager-modules
else
[ ]) ++ extraConfiguration;
in
{
makeNixOsModule =
{ system
, configuration ? null
, ...
}@attrs:
nixpkgs.lib.nixosSystem {
eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgs = eachSystem (system:
import nixpkgs {
system = system;
modules = (makeImports {
attrs = attrs;
home-manager-modules = [ home-manager.nixosModules.default ];
extraConfiguration = [ lix-module.nixosModules.default ];
});
};
config = { allowUnfree = true; };
});
makeNixOsModuleMaker =
masterAttrs:
{ system ? masterAttrs.system ? "x86_64-linux"
, configuration ? null
, ...
}@attrs:
let joinedttrs = masterAttrs // attrs;
in
nixpkgs.lib.nixosSystem {
system = system;
modules = (makeImports {
attrs = masterAttrs // attrs;
attrs = joinedttrs;
home-manager-modules = [ home-manager.nixosModules.default ];
extraConfiguration = [ lix-module.nixosModules.default ];
});
};
makeNixOsModule =
makeNixOsModuleMaker { };
makeHLService = makeNixOsModuleMaker hlCommonSettings;
makeDarwinModule =
{ system ? "x86_64-darwin"
, user
@@ -63,4 +62,25 @@ in
})
];
};
in
{
eachSystem = eachSystem;
pkgs = pkgs;
makeNixOsModule = makeNixOsModule;
makeHLService = makeHLService;
makeDarwinModule = makeDarwinModule;
makeHLServices =
{ nodeNames ? [ ]
, systemStateVersion ? "24.05"
, user
}: builtins.listToAttrs (builtins.map
(name: {
name = name;
value = makeHLService {
hostName = name;
configuration = (import (./hosts + "/${name}.nix") { user = user; });
systemStateVersion = systemStateVersion;
};
})
nodeNames);
}
+1 -2
View File
@@ -52,6 +52,5 @@
++ (if enableHomelabServices then [ (import ./hl-services) ] else [ ])
++ (if enableHomelabServices then [ (import ./hl-hardware) ] else [ ])
;
skyg.core.hostName = hostName;
skyg.user = user;
}
+2 -2
View File
@@ -8,7 +8,7 @@ in
{
options = {
skyg.core = {
hostname = mkOption {
hostName = mkOption {
description = "Machine Hostname";
type = types.str;
};
@@ -16,7 +16,7 @@ in
};
config = {
home-manager.users.root.programs.git.userName = "root@${cfg.hostName}";
home-manager.users.root.programs.git.userEmail = "root@${cfg.hostName}";
networking.hostName = cfg.hostName;
};
}
+1
View File
@@ -2,5 +2,6 @@
{
imports = [
./core.nix
./user.nix
];
}