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WBJLAC PCPSIHPNCTQYQJCQLPC6XQTZMPOE33LEOIXDPJ2ACJNLR4LYAY4AC in {home-manager.sharedModules = [{xdg.desktopEntries.rebuild = mkIf config.isDesktopNotWsl {name = "Rebuild";exec = ''nu /home/jam/rebuild.nu'';terminal = false;};xdg.desktopEntries.rebuild-plum = mkIf config.isDesktopNotWsl {name = "Rebuild plum";exec = ''nu /home/jam/rebuild.nu --remote plum'';terminal = false;};xdg.desktopEntries.rebuild-kiwi = mkIf config.isDesktopNotWsl {name = "Rebuild kiwi";exec = ''nu /home/jam/rebuild.nu --remote kiwi'';terminal = false;};xdg.desktopEntries.rollback = mkIf config.isDesktopNotWsl {name = "Rollback";exec = ''nu /home/jam/rebuild.nu --rollback'';terminal = false;};home.file."rebuild.nu" = mkIf config.isDesktop {executable = true;text = /* nu */ ''#!/usr/bin/env nu
# TODO: Make 100 progress show full bar but prevent sticky notification.def print-notify [message: string, progress: int = -1] {print $"(ansi purple)[Rebuilder] ($message)"if (which notify-send | is-not-empty) {let base_args = ["--replace-id=1003" "--print-id"]
rebuildScript = pkgs.writeScriptBin "rebuild" /* nu */ ''#!${pkgs.nushell}/bin/nu
# Don't add progress hint for completion (progress=100) so it times out.let args = if $progress >= 0 and $progress < 100 {$base_args | append ["--hint" $"int:value:($progress)"]} else {$base_args}
# TODO: Make 100 progress show full bar but prevent sticky notification.def print-notify [message: string, progress: int = -1] {print $"(ansi purple)[Rebuilder] ($message)"if (which notify-send | is-not-empty) {let base_args = ["--replace-id=1003" "--print-id"]
let timeout = if ($message | str downcase | str contains "error") { 30000 } else { 15000 }let urgency = if ($message | str downcase | str contains "error") { "critical" } else { "normal" }^notify-send ...$args --urgency=($urgency) --expire-time=($timeout) "Rebuilder" $"($message)"}
# Don't add progress hint for completion (progress=100) so it times out.let args = if $progress >= 0 and $progress < 100 {$base_args | append ["--hint" $"int:value:($progress)"]} else {$base_args
def --wrapped main [host: string = "" # The host to build.--remote # Deploy to remote host using --target-host.--rollback # Rollback.--quiet # Run without output (for theme toggling)....arguments # Extra arguments to pass to rebuild commands.]: nothing -> nothing {let host = if ($host | is-not-empty) {if $host != (hostname) and not $remote {if not $quiet { print-notify $"Error: Building local configuration for hostname that does not match the local machine." }exit 1}$host} else if $remote {if not $quiet { print-notify "Error: Hostname not specified for remote deployment." }exit 1} else {(hostname)}
let timeout = if ($message | str downcase | str contains "error") { 30000 } else { 15000 }let urgency = if ($message | str downcase | str contains "error") { "critical" } else { "normal" }
# Build locally (always).let os = (uname | get kernel-name)let config_path = if $os == "Darwin" { "/Users/jam/nixos" } else { "/home/jam/nixos" }
^notify-send ...$args --urgency=($urgency) --expire-time=($timeout) "Rebuilder" $"($message)"}}
# nh os/darwin switch [flake_path] --hostname [host] -- [nix_args]let base_args = ["switch"$config_path"--hostname" $host"--accept-flake-config" # Avoid asking for y/n approval for all settings.] | append $arguments
def --wrapped main [host: string = "" # The host to build.--remote # Deploy to remote host using --target-host.--rollback # Rollback.--quiet # Run without output (for theme toggling)....arguments # Extra arguments to pass to rebuild commands.]: nothing -> nothing {let host = if ($host | is-not-empty) {if $host != (hostname) and not $remote {if not $quiet { print-notify $"Error: Building local configuration for hostname that does not match the local machine." }exit 1}$host} else if $remote {if not $quiet { print-notify "Error: Hostname not specified for remote deployment." }exit 1} else {(hostname)}# Build locally (always).let os = (uname | get kernel-name)let config_path = if $os == "Darwin" { "/Users/jam/nixos" } else { "/home/jam/nixos" }
# Add target-host for remote deployments.let final_args = if $remote {$base_args | append ["--target-host" $"root@($host)"]} else {$base_args}
# nh os/darwin switch [flake_path] --hostname [host] -- [nix_args]let base_args = ["switch"$config_path"--hostname" $host"--accept-flake-config" # Avoid asking for y/n approval for all settings.] | append $arguments
let command = if $rollback {"rollback"} else {if $os == "Darwin" { "darwin" } else { "os" }}
# Add target-host for remote deployments.let final_args = if $remote {$base_args | append ["--target-host" $"root@($host)"]} else {$base_args}
let final_args = if $rollback {[$host] | append $arguments} else {$final_args}
let command = if $rollback {"rollback"} else {if $os == "Darwin" { "darwin" } else { "os" }}
# Execute final command.let action = if $remote { $"Deploying to: ($host)" } else { "Building locally:" }let platform = if $os == "Darwin" { "Darwin" } else { "NixOS" }if not $quiet { print-notify $"($action) ($platform). Configuration for: ($host)." 50 }
let final_args = if $rollback {[$host] | append $arguments} else {$final_args}
try {nh $command ...$final_args} catch { |e|if not $quiet { print-notify "Error: Rebuild failed, run manually in a terminal." }exit 1}
# Execute final command.let action = if $remote { $"Deploying to: ($host)" } else { "Building locally:" }let platform = if $os == "Darwin" { "Darwin" } else { "NixOS" }if not $quiet { print-notify $"($action) ($platform). Configuration for: ($host)." 50 }
if $rollback {if not $quiet { print-notify $"Rollback for ($host) succeeded." 100 }} else {if not $quiet { print-notify $"Rebuild for ($host) succeeded." 100 }}}
try {nh $command ...$final_args} catch { |e|if not $quiet { print-notify "Error: Rebuild failed, run manually in a terminal." }exit 1}
# Rollback wrapper.def rollback [host: string = ""] {main $host --rollback}'';
if $rollback {if not $quiet { print-notify $"Rollback for ($host) succeeded." 100 }} else {if not $quiet { print-notify $"Rebuild for ($host) succeeded." 100 }}}'';in {home-manager.sharedModules = mkIf config.isDesktopNotWsl [{xdg.desktopEntries.rebuild = {name = "Rebuild";exec = ''rebuild'';terminal = false;};xdg.desktopEntries.rebuild-plum = {name = "Rebuild plum";exec = ''rebuild --remote plum'';terminal = false;};xdg.desktopEntries.rebuild-kiwi = {name = "Rebuild kiwi";exec = ''rebuild --remote kiwi'';terminal = false;