chore: improve shells

This commit is contained in:
Julien Malka 2024-07-12 16:31:09 +02:00
parent f53336f887
commit c783d1123a
Signed by: Luj
GPG key ID: 6FC74C847011FD83
3 changed files with 54 additions and 31 deletions

View file

@ -1,9 +1,19 @@
let {
inputs = import ../deps; writeShellApplication,
pkgs = import inputs.nixpkgs { }; rbw,
in nixos-anywhere,
pkgs.writeShellScriptBin "bootstrap-machine" '' }:
pushd $(git rev-parse --show-toplevel)
writeShellApplication {
name = "bootstrap-machine";
runtimeInputs = [
rbw
nixos-anywhere
];
text = ''
pushd "$(git rev-parse --show-toplevel)"
machine=$1 machine=$1
ip=$2 ip=$2
extra_args=("''${@:3}") extra_args=("''${@:3}")
@ -32,6 +42,7 @@ pkgs.writeShellScriptBin "bootstrap-machine" ''
cp -r "$temp/etc" "$temp/persistent/etc" cp -r "$temp/etc" "$temp/persistent/etc"
nixos-anywhere --extra-files "$temp" --store-paths $(nix-build -A nixosConfigurations.\"$machine\".config.system.build.diskoScript) $(nix-build -A nixosConfigurations.\"$machine\".config.system.build.toplevel) "''${extra_args[@]}" root@"$ip" nixos-anywhere --extra-files "$temp" --store-paths "$(nix-build -A nixosConfigurations.\""$machine"\".config.system.build.diskoScript)" "$(nix-build -A nixosConfigurations.\""$machine"\".config.system.build.toplevel)" "''${extra_args[@]}" root@"$ip"
popd popd
'' '';
}

11
scripts/update-deps.nix Normal file
View file

@ -0,0 +1,11 @@
{ writeShellApplication, npins }:
writeShellApplication {
name = "update-deps";
runtimeInputs = [ npins ];
text = ''
npins update -d deps "$@"
'';
}

View file

@ -3,7 +3,8 @@ let
pkgs = import inputs.unstable { }; pkgs = import inputs.unstable { };
nixos-anywhere = pkgs.callPackage "${inputs.nixos-anywhere}/src/default.nix" { }; nixos-anywhere = pkgs.callPackage "${inputs.nixos-anywhere}/src/default.nix" { };
agenix = pkgs.callPackage "${inputs.agenix}/pkgs/agenix.nix" { }; agenix = pkgs.callPackage "${inputs.agenix}/pkgs/agenix.nix" { };
bootstrap = import scripts/bootstrap-machine.nix; bootstrap = pkgs.callPackage scripts/bootstrap-machine.nix { inherit nixos-anywhere; };
update-deps = pkgs.callPackage scripts/update-deps.nix { };
pre-commit-hook = pre-commit-hook =
(import ( (import (
pkgs.applyPatches { pkgs.applyPatches {
@ -32,9 +33,9 @@ pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
colmena colmena
npins npins
nixos-anywhere
agenix agenix
bootstrap bootstrap
update-deps
statix statix
rbw rbw
pinentry pinentry