separated nixos rebuild

This commit is contained in:
John Lancaster
2026-03-28 19:15:31 -05:00
parent 8ec898d874
commit 550e61eb5a
3 changed files with 59 additions and 45 deletions
+6 -3
View File
@@ -16,6 +16,8 @@
allowUnfree = true; allowUnfree = true;
}; };
flakeDir = "${config.home-manager.users.john.home.homeDirectory}/Documents/dendritic";
networking = { networking = {
hostName = hostname; hostName = hostname;
networkmanager.enable = true; networkmanager.enable = true;
@@ -66,9 +68,9 @@
time.timeZone = "America/Chicago"; time.timeZone = "America/Chicago";
# Select internationalisation properties. # Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8"; i18n = {
defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = { extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8"; LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8"; LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8"; LC_MEASUREMENT = "en_US.UTF-8";
@@ -79,6 +81,7 @@
LC_TELEPHONE = "en_US.UTF-8"; LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8"; LC_TIME = "en_US.UTF-8";
}; };
};
services.libinput.enable = true; # Enable touchpad support (enabled default in most desktopManager). services.libinput.enable = true; # Enable touchpad support (enabled default in most desktopManager).
services.fprintd.enable = true; # Enables fingerprint sensor services.fprintd.enable = true; # Enables fingerprint sensor
+1
View File
@@ -12,6 +12,7 @@
"${inputs.nixos-hardware}/lenovo/thinkpad/p14s/amd/gen4" "${inputs.nixos-hardware}/lenovo/thinkpad/p14s/amd/gen4"
] ++ (with self.modules.nixos; [ ] ++ (with self.modules.nixos; [
p14sConfiguration p14sConfiguration
rebuild
sudo sudo
john john
gnome gnome
+43 -33
View File
@@ -1,7 +1,49 @@
{ self, inputs, ... }: { self, inputs, ... }:
{ {
flake.modules.nixos.rebuild =
{ config, pkgs, lib, ... }:
let
flakeDir = config.rebuild.flakeDir;
echoCmd = lib.getExe' pkgs.coreutils "echo";
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
nfs = (pkgs.writeShellScriptBin "nfs" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME nixos profile"
sudo ${lib.getExe pkgs.nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
in
{
options.rebuild = {
flakeDir = lib.mkOption {
description = "Path to the flake directory.";
type = lib.types.str;
default = "/etc/nixos";
};
};
config = {
environment.systemPackages = with pkgs; [
nfs
(writeShellScriptBin "nfsu" ''
${lib.getExe nix} flake update --impure --flake ${flakeDir}
${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1
${lib.getExe nfs}
'')
(writeShellScriptBin "test-build" ''
if [ -z "$1" ]; then
HOSTNAME=${hostnameCmd}
else
HOSTNAME="$1"
fi
${echoCmd} "Testing the evaulation of the nixos config for $HOSTNAME"
${lib.getExe nix} eval ${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath
'')
];
};
};
flake.modules.homeManager.rebuild = flake.modules.homeManager.rebuild =
{ pkgs, lib, config, ... }: { config, pkgs, lib, ... }:
let let
nixBin = lib.getExe pkgs.nix; nixBin = lib.getExe pkgs.nix;
flakeDir = config.homeManagerFlakeDir; flakeDir = config.homeManagerFlakeDir;
@@ -12,11 +54,6 @@
${echoCmd} "Switching to the $HOSTNAME home-manager profile" ${echoCmd} "Switching to the $HOSTNAME home-manager profile"
${lib.getExe pkgs.home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME ${lib.getExe pkgs.home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
''); '');
nfs = (pkgs.writeShellScriptBin "nfs" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME nixos profile"
sudo ${lib.getExe pkgs.nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
in in
{ {
options = { options = {
@@ -39,43 +76,16 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
home-manager home-manager
#
# Flake-Parts checks
#
(writeShellScriptBin "flake-parts-check" '' (writeShellScriptBin "flake-parts-check" ''
cd ${flakeDir} cd ${flakeDir}
${nixBin} run "${flakeDir}#write-flake" ${nixBin} run "${flakeDir}#write-flake"
${nixBin} flake check ${nixBin} flake check
'') '')
#
# Home-Manager rebuilds
#
nhms nhms
(writeShellScriptBin "nhmu" '' (writeShellScriptBin "nhmu" ''
${nixBin} flake update --flake ${flakeDir} ${nixBin} flake update --flake ${flakeDir}
${lib.getExe nhms} ${lib.getExe nhms}
'') '')
#
# NixOS rebuilds
#
nfs
(writeShellScriptBin "nfsu" ''
${nixBin} flake update --impure --flake ${flakeDir}
${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1
${lib.getExe nfs}
'')
(writeShellScriptBin "test-build" ''
if [ -z "$1" ]; then
HOSTNAME=${hostnameCmd}
else
HOSTNAME="$1"
fi
${echoCmd} "Testing the evaulation of the nixos config for $HOSTNAME"
${nixBin} eval ${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath
'')
]; ];
}; };
}; };