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;
};
flakeDir = "${config.home-manager.users.john.home.homeDirectory}/Documents/dendritic";
networking = {
hostName = hostname;
networkmanager.enable = true;
@@ -66,9 +68,9 @@
time.timeZone = "America/Chicago";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
@@ -79,6 +81,7 @@
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
};
services.libinput.enable = true; # Enable touchpad support (enabled default in most desktopManager).
services.fprintd.enable = true; # Enables fingerprint sensor
+1
View File
@@ -12,6 +12,7 @@
"${inputs.nixos-hardware}/lenovo/thinkpad/p14s/amd/gen4"
] ++ (with self.modules.nixos; [
p14sConfiguration
rebuild
sudo
john
gnome
+43 -33
View File
@@ -1,7 +1,49 @@
{ 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 =
{ pkgs, lib, config, ... }:
{ config, pkgs, lib, ... }:
let
nixBin = lib.getExe pkgs.nix;
flakeDir = config.homeManagerFlakeDir;
@@ -12,11 +54,6 @@
${echoCmd} "Switching to the $HOSTNAME home-manager profile"
${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
{
options = {
@@ -39,43 +76,16 @@
home.packages = with pkgs; [
home-manager
#
# Flake-Parts checks
#
(writeShellScriptBin "flake-parts-check" ''
cd ${flakeDir}
${nixBin} run "${flakeDir}#write-flake"
${nixBin} flake check
'')
#
# Home-Manager rebuilds
#
nhms
(writeShellScriptBin "nhmu" ''
${nixBin} flake update --flake ${flakeDir}
${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
'')
];
};
};