diff --git a/cluster/staging/app/garage/deploy/garage-nix-exec2.hcl b/cluster/staging/app/garage/deploy/garage-nix2.hcl similarity index 96% rename from cluster/staging/app/garage/deploy/garage-nix-exec2.hcl rename to cluster/staging/app/garage/deploy/garage-nix2.hcl index ad36b4e..a60b506 100644 --- a/cluster/staging/app/garage/deploy/garage-nix-exec2.hcl +++ b/cluster/staging/app/garage/deploy/garage-nix2.hcl @@ -57,22 +57,21 @@ job "garage-staging" { # } task "server" { - driver = "exec2" + driver = "nix2" config { - #command = "/usr/bin/env" - command = "/run/current-system/sw/bin/nix" - args = [ - "run", + packages = [ + "bash", # so that we can enter a shell inside container "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?ref=nix-remove-system&rev=60c26fbc628d7b450ae39214b578ab6a30583d5c", - "--", - "server" ] + command = "garage" + args = [ "server" ] bind = { "/mnt/storage/garage-staging/data" = "/data", "/mnt/ssd/garage-staging/meta" = "/meta", } } + user = "root" template { data = file("../config/garage.toml") diff --git a/cluster/staging/cluster.nix b/cluster/staging/cluster.nix index 79e3cf0..71a8d98 100644 --- a/cluster/staging/cluster.nix +++ b/cluster/staging/cluster.nix @@ -77,16 +77,16 @@ ## EXPERIMENTAL ON STAGING: NIX NOMAD JOBS services.nomad.dropPrivileges = false; - # ----- nomad-driver-nix & nomad-driver-exec2 ----- + # ----- nomad-driver-nix & nomad-driver-nix2 ----- services.nomad.extraSettingsPlugins = let nomad_driver_nix = import ./nomad-driver-nix.nix { inherit pkgs; }; - nomad_driver_exec2 = import ./nomad-driver-exec2.nix { inherit pkgs; }; + nomad_driver_nix2 = import ./nomad-driver-nix2.nix { inherit pkgs; }; in [ (pkgs.symlinkJoin { name = "nomad-drivers"; paths = [ nomad_driver_nix - nomad_driver_exec2 + nomad_driver_nix2 ]; }) ]; @@ -99,22 +99,11 @@ # default config for the exec2 driver services.nomad.settings.plugin = [ { - "exec2-driver" = [ + "nix2-driver" = [ { config = [ { - bind_read_only = { - "/etc/static" = "/etc/static"; - "/etc/passwd" = "/etc/passwd"; - "/etc/resolv.conf" = "/etc/resolv.conf"; - "/etc/nix/nix.conf" = "/etc/nix/nix.conf"; - "/etc/ssl" = "/etc/ssl"; - "/etc/nsswitch.conf" = "/etc/nsswitch.conf"; - "/nix" = "/nix"; - "/bin" = "/bin"; - "/usr" = "/usr"; - "/run/current-system/sw" = "/run/current-system/sw"; - }; + # default_nixpkgs = "github:nixos/nixpkgs/nixos-22.11"; } ]; } diff --git a/deploy_nixos b/deploy_nixos index 583c391..188c8d1 100755 --- a/deploy_nixos +++ b/deploy_nixos @@ -9,7 +9,7 @@ copy cluster/$CLUSTER/node/$NIXHOST.site.nix /etc/nixos/site.nix if [ "$CLUSTER" = "staging" ]; then copy nix/nomad-driver-nix.nix /etc/nixos/nomad-driver-nix.nix - copy nix/nomad-driver-exec2.nix /etc/nixos/nomad-driver-exec2.nix + copy nix/nomad-driver-nix2.nix /etc/nixos/nomad-driver-nix2.nix fi # use ./upgrade_nixos instead to upgrade NixOS diff --git a/nix/nomad-driver-exec2.nix b/nix/nomad-driver-exec2.nix deleted file mode 100644 index 16aa8c0..0000000 --- a/nix/nomad-driver-exec2.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - pkgs ? import {} -}: -pkgs.buildGoModule rec { - pname = "nomad-driver-exec2"; - version = "0.1.0"; - - src = pkgs.fetchFromGitHub { - owner = "Alexis211"; - repo = "nomad-driver-exec2"; - rev = "14bd8f2010c3a1f90c6d1297f47ebbf46ee87dde"; - sha256 = "sha256-k75VEi2+9mS9v3bx/ygumy0niQP7bLWIgB0Zwhuky+k="; - }; - - vendorSha256 = "sha256-EQdTxVOBRYQjg7kAB+pFJYcNwk0zlsjjJxM+EO/cK84="; - - ldflags = [ - "-X github.com/Alexis211/nomad-driver-exec2/exec2.pluginVersion=${version}" - ]; - - postInstall = '' - mv $out/bin/nomad-driver-exec2 $out/bin/exec2-driver - ''; - - meta = with pkgs.lib; { - description = "Nomad exec driver with support for bind mouns"; - homepage = "https://github.com/Alexis211/nomad-driver-exec2"; - license = licenses.mpl20; - platforms = platforms.linux; - }; -} diff --git a/nix/nomad-driver-nix2.nix b/nix/nomad-driver-nix2.nix new file mode 100644 index 0000000..3883c49 --- /dev/null +++ b/nix/nomad-driver-nix2.nix @@ -0,0 +1,29 @@ +{ + pkgs ? import {} +}: +pkgs.buildGoModule rec { + pname = "nomad-driver-nix2"; + version = "0.1.0"; + + src = builtins.fetchGit { + url = "https://git.deuxfleurs.fr/lx/nomad-driver-nix2"; + rev = "d13a77952cd6404fa535b3863fca0a5bf8501af5"; + }; + + vendorSha256 = "sha256-EQdTxVOBRYQjg7kAB+pFJYcNwk0zlsjjJxM+EO/cK84="; + + ldflags = [ + "-X git.deuxfleurs.fr/lx/nomad-driver-nix2/nix2.pluginVersion=${version}" + ]; + + postInstall = '' + mv $out/bin/nomad-driver-nix2 $out/bin/nix2 + ''; + + meta = with pkgs.lib; { + description = "Nomad driver to run Nix jobs"; + homepage = "https://git.deuxfleurs.fr/lx/nomad-driver-nix2"; + license = licenses.mpl20; + platforms = platforms.linux; + }; +}