From 9e434fff4486afeb3cc3f631f6dc56492b204704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 31 Jul 2024 23:53:31 +0200 Subject: [PATCH 1/9] add extra-experimental-features for nix-command fixes https://github.com/NixOS/nixpkgs/pull/331230 --- nix-serve.psgi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix-serve.psgi b/nix-serve.psgi index 928fa3b..65a8680 100644 --- a/nix-serve.psgi +++ b/nix-serve.psgi @@ -64,7 +64,7 @@ my $app = sub { return [404, ['Content-Type' => 'text/plain'], ["Incorrect NAR hash. Maybe the path has been recreated.\n"]] unless $narHash eq "sha256:$expectedNarHash"; my $fh = new IO::Handle; - open $fh, "-|", "nix", "dump-path", "--", $storePath; + open $fh, "-|", "nix", "--extra-experimental-features", "nix-command", "dump-path", "--", $storePath; return [200, ['Content-Type' => 'text/plain', 'Content-Length' => $narSize], $fh]; } @@ -75,14 +75,14 @@ my $app = sub { return [404, ['Content-Type' => 'text/plain'], ["No such path.\n"]] unless $storePath; my ($deriver, $narHash, $time, $narSize, $refs) = $store->queryPathInfo($storePath, 1) or die; my $fh = new IO::Handle; - open $fh, "-|", "nix", "dump-path", "--", $storePath; + open $fh, "-|", "nix", "--extra-experimental-features", "nix-command", "dump-path", "--", $storePath; return [200, ['Content-Type' => 'text/plain', 'Content-Length' => $narSize], $fh]; } elsif ($path =~ /^\/log\/([0-9a-z]+-[0-9a-zA-Z\+\-\.\_\?\=]+)/) { my $storePath = "$Nix::Config::storeDir/$1"; my $fh = new IO::Handle; - open $fh, "-|", "nix", "log", $storePath; + open $fh, "-|", "nix", "--extra-experimental-features", "nix-command", "log", $storePath; return [200, ['Content-Type' => 'text/plain' ], $fh]; } From 9e200295213fdcc9abd67bcd8e67585f8ba0b70e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 07:32:41 +0000 Subject: [PATCH 2/9] Bump cachix/install-nix-action from 22 to 28 Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 28. - [Release notes](https://github.com/cachix/install-nix-action/releases) - [Commits](https://github.com/cachix/install-nix-action/compare/v22...V28) --- updated-dependencies: - dependency-name: cachix/install-nix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1362531..eaf8788 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,5 +13,5 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: cachix/install-nix-action@v23 + - uses: cachix/install-nix-action@V28 - run: nix-build -A checks.$(nix-instantiate --eval -E '(builtins.currentSystem)') From 888b6bcb441596dd553e08914c25898d44c04818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Sep 2024 09:41:37 +0200 Subject: [PATCH 3/9] make it possible to use nix-serve without overlay --- flake.nix | 29 +++++------------------------ package.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 package.nix diff --git a/flake.nix b/flake.nix index 5c8eceb..cd60d97 100644 --- a/flake.nix +++ b/flake.nix @@ -9,34 +9,15 @@ in { overlay = final: prev: { - - nix-serve = with final; stdenv.mkDerivation { - name = "nix-serve-${self.lastModifiedDate}"; - - buildInputs = [ perl nixVersions.latest.perl-bindings perlPackages.Plack perlPackages.Starman perlPackages.DBDSQLite ]; - - unpackPhase = "true"; - - installPhase = - '' - mkdir -p $out/libexec/nix-serve - cp ${./nix-serve.psgi} $out/libexec/nix-serve/nix-serve.psgi - - mkdir -p $out/bin - cat > $out/bin/nix-serve < $out/bin/nix-serve < Date: Wed, 18 Sep 2024 09:47:27 +0200 Subject: [PATCH 4/9] add basic nixos test --- flake.nix | 10 +++++++--- nixos-test.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 nixos-test.nix diff --git a/flake.nix b/flake.nix index cd60d97..4d7528f 100644 --- a/flake.nix +++ b/flake.nix @@ -22,10 +22,14 @@ defaultPackage = forAllSystems (system: self.packages.${system}.nix-serve); - checks = forAllSystems (system: { + checks = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { build = self.defaultPackage.${system}; - # FIXME: add a proper test. + } // nixpkgs.lib.optionalAttrs (pkgs.stdenv.isLinux) { + nixos-test = pkgs.callPackage ./nixos-test.nix { + nix-serve = self.defaultPackage.${system}; + }; }); - }; } diff --git a/nixos-test.nix b/nixos-test.nix new file mode 100644 index 0000000..9ed1f1f --- /dev/null +++ b/nixos-test.nix @@ -0,0 +1,26 @@ +{ hello, testers, nix-serve }: + +testers.runNixOSTest { + name = "nix-serve"; + nodes.machine = + { pkgs, ... }: + { + services.nix-serve.enable = true; + services.nix-serve.package = nix-serve; + environment.systemPackages = [ + pkgs.hello + ]; + }; + testScript = + let + pkgHash = builtins.head (builtins.match "${builtins.storeDir}/([^-]+).+" (toString hello)); + in + '' + start_all() + machine.wait_for_unit("nix-serve.service") + machine.wait_for_open_port(5000) + machine.succeed( + "curl --fail -g http://0.0.0.0:5000/nar/${pkgHash}.nar -o /tmp/hello.nar" + ) + ''; +} From b666cc92802265deffbd289679de9dec091cf502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Sep 2024 09:52:11 +0200 Subject: [PATCH 5/9] run nix flake check in ci --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaf8788..cc833ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,4 +14,4 @@ jobs: with: fetch-depth: 0 - uses: cachix/install-nix-action@V28 - - run: nix-build -A checks.$(nix-instantiate --eval -E '(builtins.currentSystem)') + - run: nix flake check From 0b34481e6aa83106b98805505b61ec8f97da8c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Sep 2024 10:02:05 +0200 Subject: [PATCH 6/9] use nixVersions.git dogfood nix before we hit a release --- flake.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4d7528f..c61c536 100644 --- a/flake.nix +++ b/flake.nix @@ -11,12 +11,16 @@ overlay = final: prev: { nix-serve = final.pkgs.callPackage ./package.nix { inherit self; + nix = final.nixVersions.git; }; }; - packages = forAllSystems (system: { + packages = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { nix-serve = nixpkgs.legacyPackages.${system}.callPackage ./package.nix { inherit self; + nix = pkgs.nixVersions.git; }; }); From 318e2404d16c0ef7237f7fe0b283d1f6e0e09de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Sep 2024 10:06:46 +0200 Subject: [PATCH 7/9] add mergify --- .mergify.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .mergify.yml diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 0000000..3c44c5e --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,14 @@ +queue_rules: + - name: default + merge_conditions: + - check-success=tests (macos-latest) + - check-success=tests (ubuntu-latest) + batch_size: 5 + merge_method: rebase +pull_request_rules: + - name: merge using the merge queue + conditions: + - base=main + - label~=merge-queue|dependencies + actions: + queue: {} From 3730ad65568781f7ab2b34e330516c56cdbf8d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Sep 2024 10:10:57 +0200 Subject: [PATCH 8/9] only build pull requests and main --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc833ae..2d86e39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,8 @@ name: "Test" on: pull_request: push: + branches: + - main jobs: tests: strategy: @@ -11,7 +13,5 @@ jobs: steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - uses: cachix/install-nix-action@V28 - run: nix flake check From 5c0d8bc0123f7cab0abcd3c785640ee96108ec00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 2 Aug 2024 09:02:06 +0200 Subject: [PATCH 9/9] also enable aarch64-darwin in flake --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c61c536..a360353 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,13 @@ let forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); - systems = [ "x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin" ]; + systems = [ + "x86_64-linux" + "aarch64-linux" + "i686-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; in { overlay = final: prev: {