moved aliases to common file and imported to all home.nix variants

new file:   common/aliases.nix
	modified:   common/home.nix
	modified:   hosts/nixos/home.nix
This commit is contained in:
2025-07-20 21:15:31 +10:00
parent fa76fb0f13
commit af2f4263cc
3 changed files with 38 additions and 26 deletions

24
common/aliases.nix Normal file
View File

@@ -0,0 +1,24 @@
{ config, pkgs, lib, ... }:
let
mySwitchCmd = ''
sudo nixos-rebuild switch \
--no-write-lock-file \
--refresh \
--flake git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#$(hostname)
'';
myTestCmd = ''
sudo nixos-rebuild test \
--no-write-lock-file \
--refresh \
--flake git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#$(hostname)
'';
in {
programs.bash = {
enable = true;
shellAliases = {
"Switch-nix" = mySwitchCmd;
"Test-nix" = myTestCmd;
};
};
}

View File

@@ -1,36 +1,18 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let {
mySwitchCmd = ''
sudo nixos-rebuild switch \ imports = [
--no-write-lock-file \ ./aliases.nix
--refresh \ ];
--flake git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#$(hostname)
'';
myTestCmd = ''
sudo nixos-rebuild test \
--no-write-lock-file \
--refresh \
--flake git+https://gitea.lan.ddnsgeek.com/beatzaplenty/nixos.git#$(hostname)
'';
in {
home.username = "nixos"; # your actual username home.username = "nixos"; # your actual username
home.homeDirectory = "/home/nixos"; home.homeDirectory = "/home/nixos";
home.stateVersion = "25.05"; # match your NixOS stateVersion home.stateVersion = "25.05"; # match your NixOS stateVersion
programs.home-manager.enable = true; # mandatory to activate HM programs.home-manager.enable = true; # mandatory to activate HM
programs.bash = { programs.bash.enable = true;
enable = true;
shellAliases = {
"Switch-nix" = mySwitchCmd;
"Test-nix" = myTestCmd;
};
initExtra = ''
# ensure loading of aliases/session variables
[[ -f ~/.profile ]] && . ~/.profile
'';
};
home.file = { home.file = {
".config/nix/nix.conf".text = '' ".config/nix/nix.conf".text = ''
@@ -43,11 +25,12 @@ programs.bash = {
git git
vim vim
tmux tmux
nano
]; ];
# Optional: set environment vars # Optional: set environment vars
home.sessionVariables = { home.sessionVariables = {
EDITOR = "vim"; EDITOR = "nano";
}; };
# Optional: enable bash (or zsh, fish...) # Optional: enable bash (or zsh, fish...)

View File

@@ -1,6 +1,11 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
imports = [
../../common/aliases.nix
];
home.username = "nixos"; # your actual username home.username = "nixos"; # your actual username
home.homeDirectory = "/home/nixos"; home.homeDirectory = "/home/nixos";
home.stateVersion = "25.05"; # match your NixOS stateVersion home.stateVersion = "25.05"; # match your NixOS stateVersion