diff --git a/flake.lock b/flake.lock index 57575c2..8675ef3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,64 @@ { "nodes": { + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1617481909, + "narHash": "sha256-SqnfOFuLuVRRNeVJr1yeEPJue/qWoCp5N6o5Kr///p4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "148f9b2f586c41b7e36e73009db43ea68c7a1a4d", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "ref": "VERSION_0_8_4", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1627638914, + "narHash": "sha256-KnMQRMDqidemayib7HUTSbKuxFaLxHUEf9bGq+ajVzo=", + "owner": "nixos", + "repo": "nix", + "rev": "c15e121e322ee5bca1d96d59cc0b693e5bd9d0bf", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "ca/queryRealisation-perl", + "repo": "nix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1606086654, - "narHash": "sha256-VFl+3eGIMqNp7cyOMJ6TjM/+UcsLKtodKoYexrlTJMI=", + "lastModified": 1624862269, + "narHash": "sha256-JFcsh2+7QtfKdJFoPibLFPLgIW6Ycnv8Bts9a7RYme0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "19db3e5ea2777daa874563b5986288151f502e27", + "rev": "f77036342e2b690c61c97202bf48f2ce13acc022", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-20.09", + "ref": "nixos-21.05-small", "type": "indirect" } }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nix": "nix", + "nixpkgs": [ + "nix", + "nixpkgs" + ] } } }, diff --git a/flake.nix b/flake.nix index 3f9828a..2b9f431 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,8 @@ { - inputs.nixpkgs.url = "nixpkgs/nixos-20.09"; + inputs.nixpkgs.follows = "nix/nixpkgs"; + inputs.nix.url = "github:nixos/nix/ca/queryRealisation-perl"; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, nix }: let forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); @@ -13,7 +14,7 @@ nix-serve = with final; stdenv.mkDerivation { name = "nix-serve-${self.lastModifiedDate}"; - buildInputs = [ perl nix.perl-bindings perlPackages.Plack perlPackages.Starman perlPackages.DBDSQLite ]; + buildInputs = [ perl nix.defaultPackage.${super.system}.passthru.perl-bindings perlPackages.Plack perlPackages.Starman perlPackages.DBDSQLite ]; unpackPhase = "true"; diff --git a/nix-serve.psgi b/nix-serve.psgi index dfa5b38..aca520d 100644 --- a/nix-serve.psgi +++ b/nix-serve.psgi @@ -15,7 +15,14 @@ my $app = sub { my $path = $env->{PATH_INFO}; if ($path eq "/nix-cache-info") { - return [200, ['Content-Type' => 'text/plain'], ["StoreDir: $Nix::Config::storeDir\nWantMassQuery: 1\nPriority: 30\n"]]; + return [200, ['Content-Type' => 'text/plain'], ["StoreDir: /nix/store\nWantMassQuery: 1\nPriority: 30\n"]]; + } + + elsif ($path =~ /^\/realisations\/(.*)\.doi/) { + my $rawDrvOutput = $1; + my $rawRealisation = queryRawRealisation($rawDrvOutput); + return [404, ['Content-Type' => 'text/plain'], ["No such derivation output.\n"]] unless $rawRealisation; + return [200, ['Content-Type' => 'text/plain'], [$rawRealisation]]; } elsif ($path =~ /^\/([0-9a-z]+)\.narinfo$/) {