diff --git a/Justfile b/Justfile deleted file mode 100644 index 094d927..0000000 --- a/Justfile +++ /dev/null @@ -1,26 +0,0 @@ -set shell := ["zsh", "-cu"] - -default: - just --list - -build: - nh os build - -switch: - nh os switch - -rollback: - sudo nixos-rebuild switch --rollback - -update input_name="": - if [ ! -z {{input_name}} ]; then \ - echo "just updating... {{input_name}}"; \ - nix flake update {{input_name}}; \ - else \ - echo "updating all..."; \ - nix flake update; \ - fi - git diff flake.lock - -remote cmd target: - ./bin/extra/build-remote-nixos {{target}} {{cmd}} \ No newline at end of file diff --git a/bin/extra/build-remote-nixos b/bin/extra/build-remote-nixos deleted file mode 100755 index 18126a7..0000000 --- a/bin/extra/build-remote-nixos +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Bootstrap -set -e -ROOT_FOLDER=$(realpath $0 | xargs dirname) -. $ROOT_FOLDER/common.sh -# Bootstrap - -# export NIX_SSHOPTS="-o RequestTTY=force" - -target=${1} -target_host=root@$target.lab.internal -profile=hl-$target - -valid_profiles=$(nix flake show --json 2> /dev/null | jq -r -c '.nixosConfigurations | keys[]' | grep "hl") - -function print_valid_targets { - echo "valid targets:" - while IFS= read -r line; do - echo $line | sed -r 's/.*hl-/ - /g' - done <<< "$valid_profiles" -} - -if [ -z $target ]; then - echo "must specify a target!" - print_valid_targets - exit 1 -fi - -if echo "$valid_profiles" | grep -qFx "$profile"; then - echo "Using [$profile]" -else - echo "Invalid target! '$profile'" - print_valid_targets - exit 1 -fi - -function run { - remote_cmd=${1} - echo -e "$BOLD$remote_cmd$NC on $YELLOW$target_host with $profile through $build_host$NC" - runcmd="nixos-rebuild --target-host $target_host --use-remote-sudo $remote_cmd --flake .#$profile" - echo -e "$BLUE$runcmd$NC" - $runcmd -} - -cmd=${2} -case $cmd in - "test" | "dry-activate" | "run" | "switch" | "build") run $cmd;; - *) - echo "invalid command" - exit 1 - ;; -esac diff --git a/bin/extra/common.sh b/bin/extra/common.sh deleted file mode 100644 index 811a9db..0000000 --- a/bin/extra/common.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -## Colors -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -NC='\033[0m' -BOLD='\033[1m' -BLUE_BOLD='\033[1;34m' -YELLOW_BOLD='\033[1;33m' \ No newline at end of file diff --git a/bin/skyg b/bin/skyg new file mode 100755 index 0000000..a3f0f52 --- /dev/null +++ b/bin/skyg @@ -0,0 +1,74 @@ +#!/usr/bin/env nu + +# Ensure we are located at the bin folder +const current_folder = path self | path dirname +cd $current_folder + +def valid_profiles [] { + nix flake show --json err> /dev/null | from json | + select nixosConfigurations | + flatten | transpose | + select column0 | rename name +} + +def is-valid-profile [name: string] { + (valid_profiles | where name == $name | length) == 1 +} + +def main [] { + help main +} + +# Build configuration +def "main build" [] { + nh os build | print +} + +# Switch configuration +def "main switch" [] { + nh os switch | print +} + +# test configuration +def "main test" [] { + nh os test | print +} + +# rollback configuration +def "main rollback" [] { + sudo nixos-rebuild switch --rollback +} + +# update some flakes +def "main update" [input_name:string = ""] { + if $input_name == "" { + print "Updating all flakes..." + nix flake update | print + } else { + print "Updating flake: $input_name" + nix flake update $input_name | print + } + git diff flake.lock | print +} + +# Deploy to remote machine +def "main remote" [cmd:string, target:string = ""] { + mut target_host = $"root@($target).lab.internal" + mut profile = $"hl-($target)" + if not (is-valid-profile $profile) { + print $"Invalid Profile ($profile), please select one of:" + return valid_profiles + } + $"Using [($profile)]" | print + const valid_cmds = [ + "test" , "dry-activate" , "run" , "switch" , "build" + ] + if not ($cmd in $valid_cmds) { + print $"Invalid command ($cmd), please select one of" + return $valid_cmds + } + $"($cmd) on ($target_host) with ($profile)" | print + mut runcmd = $"nixos-rebuild --target-host ($target_host) --use-remote-sudo ($cmd) --flake .#($profile)" + $runcmd | print + bash -c $runcmd +} diff --git a/flake.nix b/flake.nix index b508ff1..1c8c571 100644 --- a/flake.nix +++ b/flake.nix @@ -117,9 +117,6 @@ nixpkgs-fmt nixd nh - just - just-formatter - just-lsp ]; shellHook = '' export PATH=$PATH:$(pwd)/bin diff --git a/hosts/fwbook.nix b/hosts/fwbook.nix index ab8e00d..91599bf 100644 --- a/hosts/fwbook.nix +++ b/hosts/fwbook.nix @@ -114,8 +114,6 @@ in ]); in (with pkgs; [ - # python - python312 # Work postgresql @@ -152,21 +150,25 @@ in discord signal-desktop - # development - vscode - devenv - just - uv - rpi-imager - rpiboot - code-cursor-fhs - nix-prefetch + # Languages + python312 python313 - rust-analyzer + uv cargo rustc go pipx + rust-analyzer + + # development + vscode + zed-editor-fhs + devenv + just + rpi-imager + rpiboot + code-cursor-fhs + nix-prefetch # Run macos apps darling-dmg diff --git a/hosts/hl-fwdesk.nix b/hosts/hl-fwdesk.nix index 0f17937..ec62aaa 100644 --- a/hosts/hl-fwdesk.nix +++ b/hosts/hl-fwdesk.nix @@ -78,7 +78,6 @@ # development zed-editor-fhs - vscode nix-prefetch ]); services.usbmuxd.enable = true;