Browse Source

Add manifest to each package

tags/20.02
Emery Hemingway 1 year ago
parent
commit
e0c8dfed3e
2 changed files with 52 additions and 3 deletions
  1. 19
    0
      flake.lock
  2. 33
    3
      flake.nix

+ 19
- 0
flake.lock View File

@@ -1,5 +1,24 @@
1 1
 {
2 2
     "inputs": {
3
+        "dhall-haskell": {
4
+            "inputs": {
5
+                "nixpkgs": {
6
+                    "inputs": {},
7
+                    "narHash": "sha256-wJg4DA700SoQbEz61448sR6BgxRa1R92K3vvCV1g+HY=",
8
+                    "originalUrl": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148",
9
+                    "url": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148"
10
+                },
11
+                "nixpkgsStaticLinux": {
12
+                    "inputs": {},
13
+                    "narHash": "sha256-famU3pJZ4vkElV9qc71HmyRVSvcrAhfMZ0UJKpmmKP8=",
14
+                    "originalUrl": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working",
15
+                    "url": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working&rev=925aac04f4ca58aceb83beef18cb7dae0715421b"
16
+                }
17
+            },
18
+            "narHash": "sha256-KJl9ZLcMcEsLSPcwcWoc0Ac74/6HKC9LkVMeLwhyhlg=",
19
+            "originalUrl": "git+https://github.com/dhall-lang/dhall-haskell?ref=flake",
20
+            "url": "git+https://github.com/dhall-lang/dhall-haskell?ref=flake&rev=aea28adf3d10ff1982aa4ddd176d1476251b932f"
21
+        },
3 22
         "nixpkgs": {
4 23
             "inputs": {},
5 24
             "narHash": "sha256-NB+H7zK3BB//zM127FqgbG4iAfY+nS/IOyO+uGWA5Ho=",

+ 33
- 3
flake.nix View File

@@ -3,21 +3,29 @@
3 3
 
4 4
   edition = 201909;
5 5
 
6
-  outputs = { self, nixpkgs }:
6
+  inputs.dhall-haskell.uri =
7
+    "git+https://github.com/dhall-lang/dhall-haskell?ref=flake";
8
+
9
+  outputs = { self, nixpkgs, dhall-haskell }:
7 10
     let
11
+      localSystem = "x86_64-linux";
12
+      localPackages = nixpkgs.legacyPackages.${localSystem};
13
+
8 14
       unpack = baseUrl:
9 15
         { name, value }: {
10 16
           inherit name;
11
-          value = nixpkgs.legacyPackages.x86_64-linux.stdenvNoCC.mkDerivation {
17
+          value = localPackages.stdenvNoCC.mkDerivation {
12 18
             pname = name;
13 19
             inherit (value) version;
20
+            outputs = [ "out" "manifest" ];
14 21
             preferLocalBuild = true;
15
-            src = nixpkgs.legacyPackages.x86_64-linux.fetchurl {
22
+            src = localPackages.fetchurl {
16 23
               url = "${baseUrl}${name}/${value.version}.tar.xz";
17 24
               inherit (value) sha256;
18 25
             };
19 26
             dontConfigure = true;
20 27
             dontBuild = true;
28
+            buildInputs = [ dhall-haskell.packages.${localSystem}.dhall ];
21 29
             installPhase = ''
22 30
               find . -type f | while read FILE; do
23 31
                 case $FILE in
@@ -27,6 +35,28 @@
27 35
                   *) install -Dm555 -t $out/bin $FILE;;
28 36
                 esac
29 37
               done
38
+
39
+              local drv=$out
40
+              echo '{' >> manifest.tmp
41
+              if [ -d $drv/bin ]; then
42
+                echo ', bin = {' >> manifest.tmp
43
+                find $drv/bin/ -type f -printf ', %f = { mapKey = "%f", mapValue = "%p" }\n' >> manifest.tmp
44
+                echo '}' >> manifest.tmp
45
+              fi
46
+              if [ -d $drv/lib ]; then
47
+                echo ', lib = {' >> manifest.tmp
48
+                find $drv/lib/ -type f -name '*.lib.so' -printf '%f "%p"\n' \
49
+                  | awk '{print ", "gensub(/.lib.so/, "", 1, $1)" = { mapKey = \""$1"\", mapValue = "$2" }" }'>> manifest.tmp
50
+                echo '}' >> manifest.tmp
51
+              fi
52
+              if [ -d $drv/tar ]; then
53
+                echo ', tar = {' >> manifest.tmp
54
+                find $drv/tar/ -type f -name '*.tar' -printf '%f "%p"\n' \
55
+                  | awk '{print ""gensub(/.tar/, "", 1, $1)" = { mapKey = \""$1"\", mapValue = "$2" }" }'>> manifest.tmp
56
+                echo '}' >> manifest.tmp
57
+              fi
58
+              echo '}' >> manifest.tmp
59
+              dhall < manifest.tmp > $manifest
30 60
             '';
31 61
             meta = {
32 62
               license = [ "LicenseRef-Genode" ];

Loading…
Cancel
Save