mirror of
https://github.com/librephoenix/nixos-config
synced 2025-11-30 14:43:59 +05:30
Can now build specific hosts on phoenix script
This commit is contained in:
parent
d9531c16b2
commit
74ade00081
1 changed files with 61 additions and 53 deletions
|
|
@ -1,4 +1,10 @@
|
||||||
{ config, lib, pkgs, pkgs-stable, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
pkgs-stable,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
@ -24,7 +30,8 @@
|
||||||
config = {
|
config = {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
attic-client
|
attic-client
|
||||||
git git-lfs
|
git
|
||||||
|
git-lfs
|
||||||
nix-output-monitor
|
nix-output-monitor
|
||||||
(pkgs.writeScriptBin "phoenix" ''
|
(pkgs.writeScriptBin "phoenix" ''
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
|
@ -70,30 +77,28 @@
|
||||||
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
||||||
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
||||||
exit 0;
|
exit 0;
|
||||||
# TODO allow specifying host with $2 in build subcommand
|
|
||||||
elif [ "$1" = "build" ]; then
|
elif [ "$1" = "build" ]; then
|
||||||
if [ "$#" -gt 1 ]; then
|
|
||||||
echo "Warning: The 'build' command has no subcommands (no $2 subcommand)";
|
|
||||||
fi
|
|
||||||
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
||||||
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
||||||
pushd ${config.systemSettings.dotfilesDir} &> /dev/null;
|
pushd ${config.systemSettings.dotfilesDir} &> /dev/null;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#snowfire;
|
if [ "$#" -gt 1 ]; then
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
hoststobuild=("''${@:2}")
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
for i in "''${hoststobuild[@]}"
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#duskfall;
|
do
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#$i;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#zenith;
|
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
done
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
else
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#stardust;
|
hoststobuild=($(find ${config.systemSettings.dotfilesDir}/hosts -maxdepth 1 -type d \! \( -name TEMPLATE \) \! \( -name hosts \) -exec basename {} \; | xargs -d " "))
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
for i in "''${hoststobuild[@]}"
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
do
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#ori;
|
systemd-inhibit --what sleep:idle:handle-lid-switch nixos-rebuild build --flake .#$i;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
systemd-inhibit --what sleep:idle:handle-lid-switch attic push emmet ./result;
|
||||||
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
systemd-inhibit --what sleep:idle:handle-lid-switch rm ./result;
|
||||||
|
done
|
||||||
exit 0;
|
exit 0;
|
||||||
|
fi
|
||||||
elif [ "$1" = "lock" ]; then
|
elif [ "$1" = "lock" ]; then
|
||||||
if [ "$#" -gt 1 ]; then
|
if [ "$#" -gt 1 ]; then
|
||||||
echo "Warning: The 'lock' command has no subcommands (no $2 subcommand)";
|
echo "Warning: The 'lock' command has no subcommands (no $2 subcommand)";
|
||||||
|
|
@ -127,40 +132,43 @@
|
||||||
# FIXME this thing doesn't work at all
|
# FIXME this thing doesn't work at all
|
||||||
systemd.services."phoenix-system-builder" = lib.mkIf config.systemSettings.systemBuilder.enable {
|
systemd.services."phoenix-system-builder" = lib.mkIf config.systemSettings.systemBuilder.enable {
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
pkgs-stable.openssh git nix nixos-rebuild
|
pkgs-stable.openssh
|
||||||
|
git
|
||||||
|
nix
|
||||||
|
nixos-rebuild
|
||||||
];
|
];
|
||||||
script = ''
|
script = ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix"
|
export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix"
|
||||||
echo "navigating to /etc/nixos";
|
echo "navigating to /etc/nixos";
|
||||||
cd ${config.systemSettings.dotfilesDir};
|
cd ${config.systemSettings.dotfilesDir};
|
||||||
echo "running git pull";
|
echo "running git pull";
|
||||||
${pkgs.git}/bin/git pull;
|
${pkgs.git}/bin/git pull;
|
||||||
echo "running nix flake update";
|
echo "running nix flake update";
|
||||||
nix flake update;
|
nix flake update;
|
||||||
${pkgs.git}/bin/git stage *;
|
${pkgs.git}/bin/git stage *;
|
||||||
${pkgs.git}/bin/git commit -m "Updated system" || true;
|
${pkgs.git}/bin/git commit -m "Updated system" || true;
|
||||||
${pkgs.git}/bin/git push || true;
|
${pkgs.git}/bin/git push || true;
|
||||||
cd ${config.systemSettings.secretsFlakeDir};
|
cd ${config.systemSettings.secretsFlakeDir};
|
||||||
${pkgs.git}/bin/git pull;
|
${pkgs.git}/bin/git pull;
|
||||||
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
chown -R 0:0 ${config.systemSettings.dotfilesDir};
|
||||||
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
chown -R 0:0 ${config.systemSettings.secretsFlakeDir};
|
||||||
cd ${config.systemSettings.dotfilesDir};
|
cd ${config.systemSettings.dotfilesDir};
|
||||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#snowfire;
|
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#snowfire;
|
||||||
${pkgs.attic-client}/bin/attic push emmet ./result;
|
${pkgs.attic-client}/bin/attic push emmet ./result;
|
||||||
rm ./result;
|
rm ./result;
|
||||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#duskfall;
|
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#duskfall;
|
||||||
${pkgs.attic-client}/bin/attic push emmet ./result;
|
${pkgs.attic-client}/bin/attic push emmet ./result;
|
||||||
rm ./result;
|
rm ./result;
|
||||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#zenith;
|
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#zenith;
|
||||||
${pkgs.attic-client}/bin/attic push emmet ./result;
|
${pkgs.attic-client}/bin/attic push emmet ./result;
|
||||||
rm ./result;
|
rm ./result;
|
||||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#stardust;
|
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#stardust;
|
||||||
${pkgs.attic-client}/bin/attic push emmet ./result;
|
${pkgs.attic-client}/bin/attic push emmet ./result;
|
||||||
rm ./result;
|
rm ./result;
|
||||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#ori;
|
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build --flake .#ori;
|
||||||
${pkgs.attic-client}/bin/attic push emmet ./result;
|
${pkgs.attic-client}/bin/attic push emmet ./result;
|
||||||
rm ./result;
|
rm ./result;
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue