From 9b44b726c0b6eadc2e3006ec1fa1338a1a2e79f0 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 28 Apr 2024 17:03:58 +0200 Subject: [PATCH] Allow nix-command and flakes experimental Nix commands --- forgejo-nix-action.nix | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/forgejo-nix-action.nix b/forgejo-nix-action.nix index f12410c..0c09cdc 100644 --- a/forgejo-nix-action.nix +++ b/forgejo-nix-action.nix @@ -9,6 +9,19 @@ let finalImageTag = "2.22.0"; finalImageName = "nix"; }; + + nixConf = pkgs.writeText "nix.conf" '' + build-users-group = nixbld + sandbox = false + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + experimental-features = nix-command flakes + ''; + + nixConfDrv = pkgs.stdenv.mkDerivation { + name = "nix.conf"; + dontUnpack = true; + installPhase = "install -Dm755 ${nixConf} $out/etc/nix/nix.conf"; + }; in { packages.forgejo-nix-action = pkgs.dockerTools.buildImage { @@ -18,14 +31,14 @@ in copyToRoot = pkgs.buildEnv { name = "image-root"; - paths = [ pkgs.coreutils pkgs.attic-client pkgs.docker-client ]; - pathsToLink = [ "/bin" ]; + paths = with pkgs; [ coreutils attic-client docker-client nixConfDrv ]; + pathsToLink = [ "/bin" "/etc/nix" ]; }; - config = { - Env = [ - "PATH=/bin:/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin" - ]; - }; + # config = { + # Env = [ + # "PATH=/bin:/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin" + # ]; + # }; }; })