1
0
Fork 0

all: lix, deploy-rs and just

This commit is contained in:
Daniel Kempkens 2024-07-24 09:54:07 +02:00
parent c32de5aa8c
commit a62e395a20
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
6 changed files with 82 additions and 17 deletions

View file

@ -109,8 +109,8 @@
}; };
argon = import ./system/flakes/argon.nix { argon = import ./system/flakes/argon.nix {
inherit (inputs) nixpkgs nixos-hardware home-manager agenix; inherit (inputs) nixpkgs nixos-hardware home-manager agenix neovim-nightly-overlay nifoc-overlay;
inherit inputs; inherit lix-module;
}; };
neon = import ./system/flakes/neon.nix { neon = import ./system/flakes/neon.nix {
@ -201,6 +201,7 @@
packages = [ packages = [
inputs'.agenix.packages.agenix inputs'.agenix.packages.agenix
inputs'.deploy-rs.packages.default inputs'.deploy-rs.packages.default
pkgs.just
pkgs.nix-output-monitor pkgs.nix-output-monitor
]; ];

View file

@ -62,7 +62,6 @@ in
]; ];
shellAliases = { shellAliases = {
nrsw = "nixpkgs-switch";
upa = "nix flake update ~/.config/nixpkgs -v && upn"; upa = "nix flake update ~/.config/nixpkgs -v && upn";
ngc = "nix-collect-garbage -d && sudo nix-collect-garbage -d"; ngc = "nix-collect-garbage -d && sudo nix-collect-garbage -d";
nsr = "sudo nix-store --verify --check-contents --repair"; nsr = "sudo nix-store --verify --check-contents --repair";
@ -79,6 +78,37 @@ in
echo "$argv" | base64 --decode echo "$argv" | base64 --decode
''; '';
nrsw = /* fish */ ''
set -f os (uname)
set -f other_hostname $argv[1]
switch $os
case Darwin
set -f config_dir "$HOME/.config/nixpkgs"
case Linux
set -f config_dir /etc/nixos
case '*'
echo "Unsupported OS"
exit 1
end
pushd "$config_dir"
rm -rf result
if test -z "$DIRENV_DIR"
eval (direnv export fish 2>/dev/null)
end
if test "$other_hostname" = ""
just deploy-local-machine (hostname -s)
else
just deploy-remote-machine "$other_hostname"
end
rm -f result
popd
'';
upn = /* fish */ '' upn = /* fish */ ''
set -f os (uname) set -f os (uname)

View file

@ -35,7 +35,7 @@ if test "$other_hostname" = ""
end end
else else
git pull git pull
nom build --eval-store auto --store "ssh-ng://$other_hostname.ts.kempkens.network" ".#nixosConfigurations.$other_hostname.config.system.build.toplevel" nom build --eval-store auto --store "ssh-ng://root@$other_hostname.ts.kempkens.network" ".#nixosConfigurations.$other_hostname.config.system.build.toplevel"
if test $status -eq 0 if test $status -eq 0
deploy --skip-checks ".#$other_hostname" deploy --skip-checks ".#$other_hostname"
end end

29
justfile Normal file
View file

@ -0,0 +1,29 @@
default:
@just --list
# Format the entire source tree
fmt:
treefmt
# Build a local machine
build-local-machine target type='darwin':
nom build ".#{{type}}Configurations.{{target}}.config.system.build.toplevel"
# Build a remote machine
build-remote-machine target type='nixos':
nom build --eval-store auto \
--store 'ssh-ng://root@{{target}}.ts.kempkens.network' \
'.#{{type}}Configurations.{{target}}.config.system.build.toplevel'
# Deploy to a local machine
deploy-local-machine target type='darwin': _git-pull (build-local-machine target type)
env TERM=xterm-256color {{type}}-rebuild switch --flake ".#{{target}}"
attic push nifoc-systems /run/current-system
# Deploy to a remote machine
deploy-remote-machine target type='nixos': _git-pull (build-remote-machine target type)
deploy --skip-checks '.#{{target}}'
ssh -t '{{target}}' attic push nifoc-systems /run/current-system
_git-pull:
-git pull

View file

@ -1,12 +1,12 @@
{ nixpkgs, nixos-hardware, home-manager, agenix, inputs, ... }: { nixpkgs, lix-module, nixos-hardware, home-manager, agenix, neovim-nightly-overlay, nifoc-overlay }:
let let
default-system = "aarch64-linux"; default-system = "aarch64-linux";
nixpkgsConfig = { nixpkgsConfig = {
overlays = [ overlays = [
inputs.neovim-nightly-overlay.overlays.default neovim-nightly-overlay.overlays.default
inputs.nifoc-overlay.overlay nifoc-overlay.overlay
]; ];
config = { config = {
@ -23,25 +23,30 @@ in
system = nixpkgs.lib.nixosSystem { system = nixpkgs.lib.nixosSystem {
system = default-system; system = default-system;
modules = [ modules = [
../hosts/argon.nix {
nixpkgs = nixpkgsConfig;
nix = {
registry.nixpkgs.to = { type = "path"; path = nixpkgs.outPath; };
nixPath = nixpkgs.lib.mkForce [ "nixpkgs=flake:nixpkgs" ];
};
}
nixos-hardware.nixosModules.raspberry-pi-4 nixos-hardware.nixosModules.raspberry-pi-4
lix-module.nixosModules.default
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
agenix.nixosModules.default
{ {
nixpkgs = nixpkgsConfig;
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nix.registry.nixpkgs.flake = nixpkgs;
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users.daniel = import ../../home/hosts/argon.nix; users.daniel = import ../../home/hosts/argon.nix;
}; };
} }
agenix.nixosModules.default
../hosts/argon.nix
]; ];
}; };

View file

@ -45,8 +45,6 @@ in
system.stateVersion = "22.11"; system.stateVersion = "22.11";
nix = { nix = {
package = pkgs.nixVersions.stable;
settings = { settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [ "nix-command" "flakes" ];
@ -60,6 +58,7 @@ in
"https://attic.cache.daniel.sx/nifoc-ci?priority=35" "https://attic.cache.daniel.sx/nifoc-ci?priority=35"
"https://nix-community.cachix.org?priority=50" "https://nix-community.cachix.org?priority=50"
"https://cache.garnix.io?priority=60" "https://cache.garnix.io?priority=60"
"https://cache.lix.systems?priority=70"
]; ];
extra-trusted-public-keys = [ extra-trusted-public-keys = [
@ -67,6 +66,7 @@ in
"nifoc-ci:JpD9zqVQi8JuS7B8htPDOQZh08rhInMnGFS9RVhiuwk=" "nifoc-ci:JpD9zqVQi8JuS7B8htPDOQZh08rhInMnGFS9RVhiuwk="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
]; ];
trusted-users = [ trusted-users = [