chore: bump and reconfigure treefmt-nix, include just fmt

This commit is contained in:
steveej 2025-02-14 16:46:28 +01:00
parent e658e27576
commit c0daa9e6e9
13 changed files with 419 additions and 407 deletions

View file

@ -11,11 +11,10 @@
"ignored": ["unused_binding", "unused_with"]
},
"formatting": {
"command": ["treefmt-nix", "--stdin", ".nil.nix"]
"command": ["treefmt", "--stdin", ".nil.nix"]
}
}
},
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
}
"treefmt.command": "treefmt",
"treefmt.config": ""
}

View file

@ -9,14 +9,14 @@ update-default-versions:
nix flake update
_get_nix_path versionsPath:
echo $(set -x; nix-build --no-link --show-trace {{invocation_directory()}}/nix/default.nix -A channelSources --argstr versionsPath {{versionsPath}})
echo $(set -x; nix-build --no-link --show-trace {{ invocation_directory() }}/nix/default.nix -A channelSources --argstr versionsPath {{ versionsPath }})
_device recipe dir +moreargs="":
#!/usr/bin/env bash
set -ex
unset NIX_PATH
source $(just -v _get_nix_path {{invocation_directory()}}/{{dir}}/versions.nix)
$(set -x; nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A recipes.{{recipe}} --argstr dir {{dir}} {{moreargs}})
source $(just -v _get_nix_path {{ invocation_directory() }}/{{ dir }}/versions.nix)
$(set -x; nix-build --no-link --show-trace $(dirname {{ dir }})/default.nix -A recipes.{{ recipe }} --argstr dir {{ dir }} {{ moreargs }})
_render_templates:
#!/usr/bin/env bash
@ -24,18 +24,18 @@ _render_templates:
if ! ip route get 1.1.1.1; then
echo No route to WAN. Skipping template rendering...
else
source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix)
source $(just -v _get_nix_path {{ invocation_directory() }}/nix/variables/versions.nix)
# nix/scripts/pre-eval-fixed.sh nix/home-manager/profiles/dotfiles/vcsh{.tmpl,}.nix
fi
rebuild-remote-device device +rebuildargs="dry-activate":
#!/usr/bin/env bash
set -ex
nix run .#colmena -- apply --impure --on {{device}} {{rebuildargs}}
nix run .#colmena -- apply --impure --on {{ device }} {{ rebuildargs }}
# Rebuild this device's NixOS
rebuild-this-device +rebuildargs="dry-activate":
nix run .#colmena -- apply-local --impure --sudo {{rebuildargs}}
nix run .#colmena -- apply-local --impure --sudo {{ rebuildargs }}
# Re-render the versions of a remote device and rebuild its environment
update-remote-device devicename +rebuildargs='build':
@ -44,13 +44,13 @@ update-remote-device devicename +rebuildargs='build':
(
set -xe
cd nix/os/devices/{{devicename}}
cd nix/os/devices/{{ devicename }}
nix flake update
)
just -v rebuild-remote-device {{devicename}} {{rebuildargs}}
just -v rebuild-remote-device {{ devicename }} {{ rebuildargs }}
git commit -v nix/os/devices/{{devicename}}/flake.{nix,lock} -m "nix/os/devices/{{devicename}}: bump versions"
git commit -v nix/os/devices/{{ devicename }}/flake.{nix,lock} -m "nix/os/devices/{{ devicename }}: bump versions"
# Re-render the versions of the current device and rebuild its environment
update-this-device rebuild-mode='switch' +moreargs='':
@ -63,7 +63,7 @@ update-this-device rebuild-mode='switch' +moreargs='':
nix flake update
)
just -v rebuild-this-device {{rebuild-mode}} {{moreargs}}
just -v rebuild-this-device {{ rebuild-mode }} {{ moreargs }}
git commit -v nix/os/devices/$(hostname -s)/flake.{nix,lock} -m "nix/os/devices/$(hostname -s): bump versions"
@ -72,19 +72,19 @@ rebuild-disk device:
#!/usr/bin/env bash
set -xe
just -v disk-mount {{device}}
trap "set +e; just -v disk-umount {{device}}" EXIT
just -v disk-install {{device}}
just -v disk-mount {{ device }}
trap "set +e; just -v disk-umount {{ device }}" EXIT
just -v disk-install {{ device }}
# Re-render the versions of the given offline system and reinstall it in offline-mode
update-disk dir:
#!/usr/bin/env bash
set -exuo pipefail
dir={{dir}}
dir={{ dir }}
template={{dir}}/versions.tmpl.nix
outfile={{dir}}/versions.nix
template={{ dir }}/versions.tmpl.nix
outfile={{ dir }}/versions.nix
if ! test -e ${template}; then
template="$(just _DEFAULT_VERSION_TMPL)"
@ -96,9 +96,9 @@ update-disk dir:
exit 0
fi
export SYSREBUILD_LOG=.{{dir}}_sysrebuild.log
just -v rebuild-disk {{dir}} || {
echo ERROR: Update of {{dir}} failed, reverting ${outfile}...
export SYSREBUILD_LOG=.{{ dir }}_sysrebuild.log
just -v rebuild-disk {{ dir }} || {
echo ERROR: Update of {{ dir }} failed, reverting ${outfile}...
exit 1
}
@ -119,33 +119,33 @@ hm-iterate-qtile:
# !!! DANGERIOUS !!! This wipes the disk which is configured for the given device.
disk-prepare dir:
just -v _device diskPrepare {{dir}}
just -v _device diskPrepare {{ dir }}
disk-relabel dir previous:
just -v _device diskRelabel {{dir}} --argstr previousDiskId {{previous}}
just -v _device diskRelabel {{ dir }} --argstr previousDiskId {{ previous }}
# Mount the target disk specified by device configuration directory. The 'dir' argument points to a device configuration, e.g. 'nix/os/devices/steveej-live-mmc-SL32G_0x259093f6'
disk-mount dir:
just -v _device diskMount {{dir}}
just -v _device diskMount {{ dir }}
# Unmount target disk, specified by device configuration directory
disk-umount dir:
just -v _device diskUmount {{dir}}
just -v _device diskUmount {{ dir }}
# Perform an offline installation on the mounted target disk, specified by device configuration directory
disk-install dir: _render_templates
just -v _device diskInstall {{dir}}
just -v _device diskInstall {{ dir }}
verify-n-unlock sshserver attempts="10":
#!/usr/bin/env bash
set -e
env \
GETPW="just _get_pass_entry Infrastructure/VPS/{{sshserver}} DRIVE_PW" \
SSHOPTS="$(just _get_pass_entry Infrastructure/VPS/{{sshserver}} SSHOPTS)" \
VNCSOCK="$(just _get_pass_entry Infrastructure/VPS/{{sshserver}} VNCSOCK)" \
VNCPW="$(just _get_pass_entry Infrastructure/VPS/{{sshserver}} VNCPW)" \
GETPW="just _get_pass_entry Infrastructure/VPS/{{ sshserver }} DRIVE_PW" \
SSHOPTS="$(just _get_pass_entry Infrastructure/VPS/{{ sshserver }} SSHOPTS)" \
VNCSOCK="$(just _get_pass_entry Infrastructure/VPS/{{ sshserver }} VNCSOCK)" \
VNCPW="$(just _get_pass_entry Infrastructure/VPS/{{ sshserver }} VNCPW)" \
\
just _verify-n-unlock {{sshserver}} {{attempts}}
just _verify-n-unlock {{ sshserver }} {{ attempts }}
_verify-n-unlock sshserver attempts:
#!/usr/bin/env bash
@ -158,7 +158,7 @@ _verify-n-unlock sshserver attempts:
function send() {
local what="${1:?need something to send}"
ssh -4 ${SSHOPTS:?need sshopts} root@{{sshserver}} "echo -e ${what}>> /dev/tty0" &>/dev/null
ssh -4 ${SSHOPTS:?need sshopts} root@{{ sshserver }} "echo -e ${what}>> /dev/tty0" &>/dev/null
}
function expect() {
@ -181,7 +181,7 @@ _verify-n-unlock sshserver attempts:
trap 'E=$?; set +e; rm screenshot.*; echo Exiting...; kill $(jobs -p | cut -d " " -f 4); exit $E' EXIT
for i in `seq 1 {{attempts}}`; do
for i in `seq 1 {{ attempts }}`; do
echo Attempt $i...
expect="$(pwgen -0 12)"
send="'\0033\0143'${expect}"
@ -192,7 +192,7 @@ _verify-n-unlock sshserver attempts:
rm ${pipe}
echo Verification succeeded at attempt $i. Unlocking remote drive...
ssh -4 ${SSHOPTS} root@{{sshserver}} "cryptsetup-askpass" <&3 &>/dev/null &
ssh -4 ${SSHOPTS} root@{{ sshserver }} "cryptsetup-askpass" <&3 &>/dev/null &
eval ${GETPW} | head -n1 >&3
for j in `seq 1 120`; do
@ -207,19 +207,19 @@ _verify-n-unlock sshserver attempts:
exit 1
fi
done
echo Verification failed {{attempts}} times. Giving up...
echo Verification failed {{ attempts }} times. Giving up...
exit 1
_get_pass_entry path key:
pass show {{path}}| grep -E "^{{key}}:" | sed -E 's/^[^:]+: *//g'
pass show {{ path }}| grep -E "^{{ key }}:" | sed -E 's/^[^:]+: *//g'
run-with-channels +cmds:
#!/usr/bin/env bash
source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix)
{{cmds}}
source $(just -v _get_nix_path {{ invocation_directory() }}/nix/variables/versions.nix)
{{ cmds }}
install-config config root:
sudo just run-with-channels nixos-install -I nixos-config={{invocation_directory()}}/{{config}} --root {{root}} --no-root-passwd
sudo just run-with-channels nixos-install -I nixos-config={{ invocation_directory() }}/{{ config }} --root {{ root }} --no-root-passwd
# Switch between gpg-card capable devices which have a copy of the same key
switch-gpg-card:
@ -253,7 +253,7 @@ switch-gpg-card:
uuid-to-device-name remote:
#!/usr/bin/env bash
set -e -o pipefail
ssh {{remote}} 'nix run nixpkgs.dmidecode -c dmidecode -s system-uuid' | xxhsum --quiet -H1 | awk '{print $1}'
ssh {{ remote }} 'nix run nixpkgs.dmidecode -c dmidecode -s system-uuid' | xxhsum --quiet -H1 | awk '{print $1}'
test-connection:
#! /usr/bin/env nix-shell
@ -305,7 +305,7 @@ test-connection:
done
cachix-use name:
nix run nixpkgs/nixos-unstable#cachix -- use {{name}} -m nixos -d nix/os/
nix run nixpkgs/nixos-unstable#cachix -- use {{ name }} -m nixos -d nix/os/
update-sops-keys:
for file in $(egrep -lr '"?sops"?:') secrets; do sops updatekeys -y $file; done

View file

@ -278,7 +278,6 @@
};
};
local-xwayland = pkgs.writeShellScriptBin "local-xwayland" ''
set -x
${pkgs.wayland-proxy-virtwl}/bin/wayland-proxy-virtwl \
@ -355,6 +354,13 @@
shellcheck.enable = true;
prettier.enable = true;
just = {
enable = true;
includes = [
"*/Justfile"
"Justfile"
];
};
} // pkgs.lib.optionalAttrs (pkgs.system != "riscv64-linux") { shellcheck.enable = true; };
settings = {
@ -410,7 +416,10 @@
;
};
in
all // { default = all.develop; };
all
// {
default = all.develop;
};
};
}
);

View file

@ -93,11 +93,11 @@
self.nixosConfigurations.sj-srv1.config.containers.webserver.config.services.kanidm.serverSettings.origin;
shellHook = builtins.concatStringsSep "\n" [
(self.inputs.nixago.lib.${pkgs.system}.make {
data = self'.formatter.settings;
output = "treefmt.toml";
format = "toml";
}).shellHook
# (self.inputs.nixago.lib.${pkgs.system}.make {
# data = self'.formatter.settings;
# output = "treefmt.toml";
# format = "toml";
# }).shellHook
];
};
}

View file

@ -162,7 +162,10 @@ let
"devtools.debugger.remote-enabled" = true;
# disable translations for some languages
"browser.translations.neverTranslateLanguages" = ["en" "de"];
"browser.translations.neverTranslateLanguages" = [
"en"
"de"
];
"browser.translations.automaticallyPopup" = false;
# enable pipewire (and libcamera) sources
@ -303,7 +306,9 @@ in
repoFlake.inputs.nur.overlay
];
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
nixpkgs.config.allowUnfreePredicate =
pkg:
builtins.elem (lib.getName pkg) [
"youtube-recommended-videos"
];

View file

@ -13,8 +13,7 @@
srvos.url = "github:numtide/srvos";
srvos.inputs.nixpkgs.follows = "nixpkgs";
nixos-sbc.url =
"github:nakato/nixos-sbc"
nixos-sbc.url = "github:nakato/nixos-sbc"
# "github:steveej-forks/nakato_nixos-sbc//bpi-r3_kernel-6.12"
# "github:steveej-forks/nakato_nixos-sbc//bpi-r3_kernel-6.13"
# "github:steveej-forks/nakato_nixos-sbc/kernel-6.9_and_cross-compile"

View file

@ -6,7 +6,6 @@
config,
nodeName,
system,
packages',
...
}:
{

View file

@ -15,8 +15,7 @@
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-x13s.url =
"git+https://forgejo.www.stefanjunker.de/steveej/nixos-x13s.git?ref=bump"
nixos-x13s.url = "git+https://forgejo.www.stefanjunker.de/steveej/nixos-x13s.git?ref=bump"
# 6.13-rc2
# "git+https://forgejo.www.stefanjunker.de/steveej/nixos-x13s.git?ref=bump&rev=c95058f8aa1b361df3874429c5dc0f694f9cba78"
# 6.11.0
@ -89,7 +88,9 @@
inherit mkNixosConfiguration;
};
overlays.default = _final: _previous: {
overlays.default =
_final: _previous:
{
};
nixosConfigurations = {

View file

@ -1,5 +1,5 @@
_run_ssh_cmd cmd:
ssh root@router-family.lan "{{cmd}}"
ssh root@router-family.lan "{{ cmd }}"
post-setup:
just -v _run_ssh_cmd "opkg update"

View file

@ -1,5 +1,5 @@
_run_ssh_cmd cmd:
ssh root@router-wan.dmz "{{cmd}}"
ssh root@router-wan.dmz "{{ cmd }}"
post-setup:
just -v _run_ssh_cmd "opkg update"