Merge pull request #299618 from TomaSajt/dub-support

Add buildDubPackage and dub-to-nix for building dub based packages

authored by Atemu and committed by GitHub b136700c d5da6daf

+505 -176
+69
doc/languages-frameworks/dlang.section.md
··· 1 + # D (Dlang) {#dlang} 2 + 3 + Nixpkgs provides multiple D compilers such as `ldc`, `dmd` and `gdc`. 4 + These can be used like any other package during build time. 5 + 6 + However, Nixpkgs provides a build helper for compiling packages using the `dub` package manager. 7 + 8 + Here's an example: 9 + ```nix 10 + { 11 + lib, 12 + buildDubPackage, 13 + fetchFromGitHub, 14 + ncurses, 15 + zlib, 16 + }: 17 + 18 + buildDubPackage rec { 19 + pname = "btdu"; 20 + version = "0.5.1"; 21 + 22 + src = fetchFromGitHub { 23 + owner = "CyberShadow"; 24 + repo = "btdu"; 25 + rev = "v${version}"; 26 + hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE="; 27 + }; 28 + 29 + # generated by dub-to-nix, see below 30 + dubLock = ./dub-lock.json; 31 + 32 + buildInputs = [ 33 + ncurses 34 + zlib 35 + ]; 36 + 37 + installPhase = '' 38 + runHook preInstall 39 + install -Dm755 btdu -t $out/bin 40 + runHook postInstall 41 + ''; 42 + } 43 + ``` 44 + 45 + Note that you need to define `installPhase` because `dub` doesn't know where files should go in `$out`. 46 + 47 + Also note that running `dub test` is disabled by default. You can enable it by setting `doCheck = true`. 48 + 49 + ## Lockfiles {#dub-lockfiles} 50 + Nixpkgs has its own lockfile format for `dub` dependencies, because `dub`'s official "lockfile" format (`dub.selections.json`) is not hash based. 51 + 52 + A lockfile can be generated using the `dub-to-nix` helper package. 53 + * Firstly, install `dub-to-nix` into your shell session by running `nix-shell -p dub-to-nix` 54 + * Then navigate to the root of the source of the program you want to package 55 + * Finally, run `dub-to-nix` and it will print the lockfile to stdout. You could pipe stdout into a text file or just copy the output manually into a file. 56 + 57 + ## `buildDubPackage` parameters {#builddubpackage-parameters} 58 + 59 + The `buildDubPackage` function takes an attrset of parameters that are passed on to `stdenv.mkDerivation`. 60 + 61 + The following parameters are specific to `buildDubPackage`: 62 + 63 + * `dubLock`: A lockfile generated by `dub-to-nix` from the source of the package. Can be either a path to the file, or an attrset already parsed with `lib.importJSON`. 64 + The latter useful if the package uses `dub` dependencies not already in the lockfile. (e.g. if the package calls `dub run some-dub-package` manually) 65 + * `dubBuildType ? "release"`: The build type to pass to `dub build` as a value for the `--build=` flag. 66 + * `dubFlags ? []`: The flags to pass to `dub build` and `dub test`. 67 + * `dubBuildFlags ? []`: The flags to pass to `dub build`. 68 + * `dubTestFlags ? []`: The flags to pass to `dub test`. 69 + * `compiler ? ldc`: The D compiler to be used by `dub`.
+1
doc/languages-frameworks/index.md
··· 14 14 cuelang.section.md 15 15 dart.section.md 16 16 dhall.section.md 17 + dlang.section.md 17 18 dotnet.section.md 18 19 emscripten.section.md 19 20 gnome.section.md
+3
nixos/doc/manual/release-notes/rl-2405.section.md
··· 402 402 The `nimPackages` and `nim2Packages` sets have been removed. 403 403 See https://nixos.org/manual/nixpkgs/unstable#nim for more information. 404 404 405 + - Programs written in [D](https://dlang.org/) using the `dub` build system and package manager can now be built using `buildDubPackage` utilizing lockfiles provided by the new `dub-to-nix` helper program. 406 + See the [D section](https://nixos.org/manual/nixpkgs/unstable#dlang) in the manual for more information. 407 + 405 408 - [Portunus](https://github.com/majewsky/portunus) has been updated to major version 2. 406 409 This version of Portunus supports strong password hashes, but the legacy hash SHA-256 is also still supported to ensure a smooth migration of existing user accounts. 407 410 After upgrading, follow the instructions on the [upstream release notes](https://github.com/majewsky/portunus/releases/tag/v2.0.0) to upgrade all user accounts to strong password hashes.
+7
pkgs/build-support/dlang/README.md
··· 1 + # Build support for D 2 + 3 + Build utilities for the D language can be found in this directory. 4 + 5 + ### Current maintainers 6 + - @TomaSajt 7 + - @jtbx
+124
pkgs/build-support/dlang/builddubpackage/default.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchurl, 5 + linkFarm, 6 + dub, 7 + ldc, 8 + removeReferencesTo, 9 + }: 10 + 11 + # See https://nixos.org/manual/nixpkgs/unstable#dlang for more detailed usage information 12 + 13 + { 14 + # A lockfile generated by `dub-to-nix` from the source of the package. 15 + # Can be either a path to the file, or an attrset already parsed with `lib.importJSON`. 16 + dubLock, 17 + # The build type to pass to `dub build` as a value for the `--build=` flag. 18 + dubBuildType ? "release", 19 + # The flags to pass to `dub build` and `dub test`. 20 + dubFlags ? [ ], 21 + # The flags to pass to `dub build`. 22 + dubBuildFlags ? [ ], 23 + # The flags to pass to `dub test`. 24 + dubTestFlags ? [ ], 25 + # The D compiler to be used by `dub`. 26 + compiler ? ldc, 27 + ... 28 + }@args: 29 + 30 + let 31 + makeDubDep = 32 + { 33 + pname, 34 + version, 35 + sha256, 36 + }: 37 + { 38 + inherit pname version; 39 + src = fetchurl { 40 + name = "dub-${pname}-${version}.zip"; 41 + url = "mirror://dub/${pname}/${version}.zip"; 42 + inherit sha256; 43 + }; 44 + }; 45 + 46 + lockJson = if lib.isPath dubLock then lib.importJSON dubLock else dubLock; 47 + 48 + lockedDeps = lib.mapAttrsToList ( 49 + pname: { version, sha256 }: makeDubDep { inherit pname version sha256; } 50 + ) lockJson.dependencies; 51 + 52 + # a directory with multiple single element registries 53 + # one big directory with all .zip files leads to version parsing errors 54 + # when the name of a package is a prefix of the name of another package 55 + dubRegistryBase = linkFarm "dub-registry-base" ( 56 + map (dep: { 57 + name = "${dep.pname}/${dep.pname}-${dep.version}.zip"; 58 + path = dep.src; 59 + }) lockedDeps 60 + ); 61 + 62 + combinedFlags = "--skip-registry=all --compiler=${lib.getExe compiler} ${toString dubFlags}"; 63 + combinedBuildFlags = "${combinedFlags} --build=${dubBuildType} ${toString dubBuildFlags}"; 64 + combinedTestFlags = "${combinedFlags} ${toString dubTestFlags}"; 65 + in 66 + stdenv.mkDerivation ( 67 + builtins.removeAttrs args [ "dubLock" ] 68 + // { 69 + strictDeps = args.strictDeps or true; 70 + 71 + nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ 72 + dub 73 + compiler 74 + removeReferencesTo 75 + ]; 76 + 77 + configurePhase = 78 + args.configurePhase or '' 79 + runHook preConfigure 80 + 81 + export DUB_HOME="$NIX_BUILD_TOP/.dub" 82 + mkdir -p $DUB_HOME 83 + 84 + # register dependencies 85 + ${lib.concatMapStringsSep "\n" (dep: '' 86 + dub fetch ${dep.pname}@${dep.version} --cache=user --skip-registry=standard --registry=file://${dubRegistryBase}/${dep.pname} 87 + '') lockedDeps} 88 + 89 + runHook postConfigure 90 + ''; 91 + 92 + buildPhase = 93 + args.buildPhase or '' 94 + runHook preBuild 95 + 96 + dub build ${combinedBuildFlags} 97 + 98 + runHook postBuild 99 + ''; 100 + 101 + doCheck = args.doCheck or false; 102 + 103 + checkPhase = 104 + args.checkPhase or '' 105 + runHook preCheck 106 + 107 + dub test ${combinedTestFlags} 108 + 109 + runHook postCheck 110 + ''; 111 + 112 + preFixup = '' 113 + ${args.preFixup or ""} 114 + 115 + find "$out" -type f -exec remove-references-to -t ${compiler} '{}' + 116 + ''; 117 + 118 + disallowedReferences = [ compiler ]; 119 + 120 + meta = { 121 + platforms = dub.meta.platforms; 122 + } // args.meta or { }; 123 + } 124 + )
+5
pkgs/build-support/dlang/dub-support.nix
··· 1 + { callPackage }: 2 + { 3 + buildDubPackage = callPackage ./builddubpackage { }; 4 + dub-to-nix = callPackage ./dub-to-nix { }; 5 + }
+19
pkgs/build-support/dlang/dub-to-nix/default.nix
··· 1 + { 2 + lib, 3 + runCommand, 4 + makeWrapper, 5 + python3, 6 + nix, 7 + }: 8 + 9 + runCommand "dub-to-nix" 10 + { 11 + nativeBuildInputs = [ makeWrapper ]; 12 + buildInputs = [ python3 ]; 13 + } 14 + '' 15 + install -Dm755 ${./dub-to-nix.py} "$out/bin/dub-to-nix" 16 + patchShebangs "$out/bin/dub-to-nix" 17 + wrapProgram "$out/bin/dub-to-nix" \ 18 + --prefix PATH : ${lib.makeBinPath [ nix ]} 19 + ''
+39
pkgs/build-support/dlang/dub-to-nix/dub-to-nix.py
··· 1 + #!/usr/bin/env python3 2 + 3 + import sys 4 + import json 5 + import os 6 + import subprocess 7 + 8 + def eprint(text: str): 9 + print(text, file=sys.stderr) 10 + 11 + if not os.path.exists("dub.selections.json"): 12 + eprint("The file `dub.selections.json` does not exist in the current working directory") 13 + eprint("run `dub upgrade --annotate` to generate it") 14 + sys.exit(1) 15 + 16 + with open("dub.selections.json") as f: 17 + selectionsJson = json.load(f) 18 + 19 + versionDict: dict[str, str] = selectionsJson["versions"] 20 + 21 + for pname in versionDict: 22 + version = versionDict[pname] 23 + if version.startswith("~"): 24 + eprint(f'Package "{pname}" has a branch-type version "{version}", which doesn\'t point to a fixed version') 25 + eprint("You can resolve it by manually changing the required version to a fixed one inside `dub.selections.json`") 26 + eprint("When packaging, you might need to create a patch for `dub.sdl` or `dub.json` to accept the changed version") 27 + sys.exit(1) 28 + 29 + lockedDependenciesDict: dict[str, dict[str, str]] = {} 30 + 31 + for pname in versionDict: 32 + version = versionDict[pname] 33 + eprint(f"Fetching {pname}@{version}") 34 + url = f"https://code.dlang.org/packages/{pname}/{version}.zip" 35 + command = ["nix-prefetch-url", "--type", "sha256", url] 36 + sha256 = subprocess.run(command, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.rstrip() 37 + lockedDependenciesDict[pname] = {"version": version, "sha256": sha256} 38 + 39 + print(json.dumps({"dependencies": lockedDependenciesDict}, indent=2))
+5
pkgs/build-support/fetchurl/mirrors.nix
··· 312 312 "https://backpan.perl.org/" # for old releases 313 313 ]; 314 314 315 + # D DUB 316 + dub = [ 317 + "https://code.dlang.org/packages/" 318 + ]; 319 + 315 320 # Haskell Hackage 316 321 hackage = [ 317 322 "https://hackage.haskell.org/package/"
+112
pkgs/by-name/se/serve-d/dub-lock.json
··· 1 + { 2 + "dependencies": { 3 + "automem": { 4 + "version": "0.6.9", 5 + "sha256": "05zk8h81ih5jc4n8d7kgr6hv5f923ybf2pdyf2ld3imkx0zb0plr" 6 + }, 7 + "cachetools": { 8 + "version": "0.4.1", 9 + "sha256": "1407cb3mm8pqlcljdi60lpz2vhsj6rwzax0j24xggmyhr7ij6gx7" 10 + }, 11 + "dcd": { 12 + "version": "0.13.6", 13 + "sha256": "19fnp5hdk2n7z5s57a445a92xd4iadh7lbw14sq1pr4zyks32114" 14 + }, 15 + "dfmt": { 16 + "version": "0.14.1", 17 + "sha256": "1czk48dylq05iwi9137hy694c43whiqnmvgc5k7c32bjzzpi5pyq" 18 + }, 19 + "diet-complete": { 20 + "version": "0.0.3", 21 + "sha256": "1klzivhzb185m38jvmm957s38mllpa2rkkv8az8ipmwdjj8z6mpv" 22 + }, 23 + "dscanner": { 24 + "version": "0.12.2", 25 + "sha256": "12zhby1vj28fsryv7j6xhdiiw8d7dk1d00sarpimfpl77ajmpia8" 26 + }, 27 + "dsymbol": { 28 + "version": "0.11.3", 29 + "sha256": "0flnh8b1hc97hlm86ilb0kc194vib5cpqf8abxfbv24czxp6gfv7" 30 + }, 31 + "dub": { 32 + "version": "1.26.1", 33 + "sha256": "0sbixp7dpixlp1hwjlmnlh4dwci9f2fadxg42j8ha86rx7ggprqi" 34 + }, 35 + "dunit": { 36 + "version": "1.0.16", 37 + "sha256": "0p9g4h5qanbg6281x1068mdl5p7zvqig4zmmi72a2cay6dxnbvxb" 38 + }, 39 + "emsi_containers": { 40 + "version": "0.8.0", 41 + "sha256": "032j0rrlnhx0z2xrg9pfhb1darzj4h8qvxhixiw8gwz5izaxq1ny" 42 + }, 43 + "eventsystem": { 44 + "version": "1.2.0", 45 + "sha256": "0spg6p8rxihdn473pmwxghbkkzzccamkqxdcqaqf6k06zvjl7qfs" 46 + }, 47 + "inifiled": { 48 + "version": "1.3.3", 49 + "sha256": "01hw0lb9n6vwmx6vj5nq2awg54l5pvngqhzxfj2kmg99az84dg6d" 50 + }, 51 + "isfreedesktop": { 52 + "version": "0.1.1", 53 + "sha256": "0bnjr9avvhl7s09dnbcdr5437yb18jj26fzvm7j292kvd2i8kzqz" 54 + }, 55 + "libddoc": { 56 + "version": "0.7.4", 57 + "sha256": "1cs4nycn0pl30354dccb2akmbcdmz22yq28sn3imvfndmh059szi" 58 + }, 59 + "libdparse": { 60 + "version": "0.19.4", 61 + "sha256": "1nyhga4qxkkf1qs3sd07mnyifw81dbz3nwm1vj106kair0d25q0b" 62 + }, 63 + "msgpack-d": { 64 + "version": "1.0.1", 65 + "sha256": "1b6v667ymns90n0ssg7bd8fny1ashv5axpa8xf461ghzqnkkh05d" 66 + }, 67 + "painlessjson": { 68 + "version": "1.4.0", 69 + "sha256": "0gy71wbssgn7z50gy8fg3mmwk82qp3y17ypl3x10jbc9nczipryi" 70 + }, 71 + "painlesstraits": { 72 + "version": "0.3.0", 73 + "sha256": "0li4n0v70x5sgnqv60v5481jqlv22mk338cww4d3z5l0nhng3bvh" 74 + }, 75 + "requests": { 76 + "version": "2.1.2", 77 + "sha256": "10332kdsjv30zkayx3vg6lxa701wmdncf0xjxwxkcjpsw7smzs2z" 78 + }, 79 + "rm-rf": { 80 + "version": "0.1.0", 81 + "sha256": "0yr2jan7m49y0c6vm8nblvmgqqzw1c19g5m3cb412wwa37k12v5d" 82 + }, 83 + "silly": { 84 + "version": "1.1.1", 85 + "sha256": "1l0mpnbz8h3ihjxvk5qwn6p6lwb75g259k7fjqasw0zp0c27bkjb" 86 + }, 87 + "standardpaths": { 88 + "version": "0.8.1", 89 + "sha256": "026sy2ywi708s3kx6ca55nkbq1hn3bcj9804bf01dvxnlschmlvc" 90 + }, 91 + "stdx-allocator": { 92 + "version": "2.77.5", 93 + "sha256": "1g8382wr49sjyar0jay8j7y2if7h1i87dhapkgxphnizp24d7kaj" 94 + }, 95 + "test_allocator": { 96 + "version": "0.3.4", 97 + "sha256": "1xpjz6smxwgm4walrv3xbzi46cddc80q5n4gs7j9gm2yx11sf7gj" 98 + }, 99 + "unit-threaded": { 100 + "version": "0.10.8", 101 + "sha256": "1jvmxka6s2zzrxns62jb50p01bgybhbkrkgi9qzq93xldc6jn2i9" 102 + }, 103 + "workspace-d": { 104 + "version": "3.7.0", 105 + "sha256": "0alhmb64v7sbm1g9pdsng3fqy941s67lsqxjcf8awg1z7kn3l1hv" 106 + }, 107 + "xdgpaths": { 108 + "version": "0.2.5", 109 + "sha256": "09l3bkcldv7ckh3d2cmivvj3cbql96a24g3khlz7zp9f1aabfykl" 110 + } 111 + } 112 + }
+39
pkgs/by-name/se/serve-d/package.nix
··· 1 + { 2 + lib, 3 + buildDubPackage, 4 + fetchFromGitHub, 5 + dtools, 6 + }: 7 + 8 + buildDubPackage rec { 9 + pname = "serve-d"; 10 + version = "0.7.6"; 11 + 12 + src = fetchFromGitHub { 13 + owner = "Pure-D"; 14 + repo = "serve-d"; 15 + rev = "v${version}"; 16 + hash = "sha256-h4zsW8phGcI4z0uMCIovM9cJ6hKdk8rLb/Jp4X4dkpk="; 17 + }; 18 + 19 + nativeBuildInputs = [ dtools ]; 20 + 21 + dubLock = ./dub-lock.json; 22 + 23 + doCheck = true; 24 + 25 + installPhase = '' 26 + runHook preInstall 27 + install -Dm755 serve-d -t $out/bin 28 + runHook postInstall 29 + ''; 30 + 31 + meta = { 32 + changelog = "https://github.com/Pure-D/serve-d/releases/tag/${src.rev}"; 33 + description = "D LSP server (dlang language server protocol server)"; 34 + homepage = "https://github.com/Pure-D/serve-d"; 35 + license = lib.licenses.mit; 36 + mainProgram = "serve-d"; 37 + maintainers = with lib.maintainers; [ tomasajt ]; 38 + }; 39 + }
+1
pkgs/development/compilers/ldc/generic.nix
··· 130 130 homepage = "https://github.com/ldc-developers/ldc"; 131 131 # from https://github.com/ldc-developers/ldc/blob/master/LICENSE 132 132 license = with licenses; [ bsd3 boost mit ncsa gpl2Plus ]; 133 + mainProgram = "ldc2"; 133 134 maintainers = with maintainers; [ lionello jtbx ]; 134 135 platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 135 136 };
+21 -9
pkgs/development/tools/literate-programming/Literate/default.nix
··· 1 - { lib, stdenv, fetchFromGitHub, ldc, dub }: 1 + { 2 + lib, 3 + buildDubPackage, 4 + fetchFromGitHub, 5 + }: 2 6 3 - stdenv.mkDerivation { 7 + buildDubPackage { 4 8 pname = "Literate"; 5 9 version = "unstable-2021-01-22"; 6 10 ··· 8 12 owner = "zyedidia"; 9 13 repo = "Literate"; 10 14 rev = "7004dffec0cff3068828514eca72172274fd3f7d"; 11 - sha256 = "sha256-erNFe0+FlrslEENyO/YxYQbmec0voK31UWr5qVt+nXQ="; 15 + hash = "sha256-erNFe0+FlrslEENyO/YxYQbmec0voK31UWr5qVt+nXQ="; 12 16 fetchSubmodules = true; 13 17 }; 14 18 15 - buildInputs = [ ldc dub ]; 19 + # as there aren't any non-local dub dependencies, this file just has any empty list 20 + dubLock = ./dub-lock.json; 16 21 17 - HOME = "home"; 22 + # generate the actual .d source files defined in .lit files 23 + preBuild = '' 24 + make d-files 25 + ''; 18 26 19 - installPhase = "install -D bin/lit $out/bin/lit"; 27 + installPhase = '' 28 + runHook preInstall 29 + install -Dm755 bin/lit -t $out/bin 30 + runHook preInstall 31 + ''; 20 32 21 - meta = with lib; { 33 + meta = { 22 34 description = "A literate programming tool for any language"; 23 35 homepage = "https://zyedidia.github.io/literate/"; 24 - license = licenses.mit; 36 + license = lib.licenses.mit; 25 37 mainProgram = "lit"; 26 - platforms = platforms.unix; 38 + platforms = lib.platforms.unix; 27 39 }; 28 40 }
+3
pkgs/development/tools/literate-programming/Literate/dub-lock.json
··· 1 + { 2 + "dependencies": {} 3 + }
+34 -85
pkgs/tools/misc/btdu/default.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchurl 4 - , dub 5 - , ncurses 6 - , ldc 7 - , zlib 8 - , removeReferencesTo 1 + { 2 + lib, 3 + buildDubPackage, 4 + fetchFromGitHub, 5 + ncurses, 6 + zlib, 9 7 }: 10 8 11 - let 12 - _d_ae_ver = "0.0.3236"; 13 - _d_btrfs_ver = "0.0.18"; 14 - _d_ncurses_ver = "1.0.0"; 15 - _d_emsi_containers_ver = "0.9.0"; 16 - in 17 - stdenv.mkDerivation rec { 18 - pname = "btdu"; 19 - version = "0.5.1"; 9 + buildDubPackage rec { 10 + pname = "btdu"; 11 + version = "0.5.1"; 20 12 21 - srcs = [ 22 - (fetchurl { 23 - url = "https://github.com/CyberShadow/${pname}/archive/v${version}.tar.gz"; 24 - sha256 = "566269f365811f6db53280fc5476a7fcf34791396ee4e090c150af4280b35ba5"; 25 - }) 26 - (fetchurl { 27 - url = "https://github.com/CyberShadow/ae/archive/v${_d_ae_ver}.tar.gz"; 28 - sha256 = "5ea3f0d9d2d13012ce6a1ee1b52d9fdff9dfb1d5cc7ee5d1b04cab1947ed4d36"; 29 - }) 30 - (fetchurl { 31 - url = "https://github.com/CyberShadow/d-btrfs/archive/v${_d_btrfs_ver}.tar.gz"; 32 - sha256 = "32af4891d93c7898b0596eefb8297b88d3ed5c14c84a5951943b7b54c7599dbd"; 33 - }) 34 - (fetchurl { 35 - url = "https://github.com/D-Programming-Deimos/ncurses/archive/v${_d_ncurses_ver}.tar.gz"; 36 - sha256 = "b5db677b75ebef7a1365ca4ef768f7344a2bc8d07ec223a2ada162f185d0d9c6"; 37 - }) 38 - (fetchurl { 39 - url = "https://github.com/dlang-community/containers/archive/v${_d_emsi_containers_ver}.tar.gz"; 40 - sha256 = "5e256b84bbdbd2bd625cba0472ea27a1fde6d673d37a85fe971a20d52874acaa"; 41 - }) 42 - ]; 13 + src = fetchFromGitHub { 14 + owner = "CyberShadow"; 15 + repo = "btdu"; 16 + rev = "v${version}"; 17 + hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE="; 18 + }; 43 19 44 - sourceRoot = "."; 20 + dubLock = ./dub-lock.json; 45 21 46 - postUnpack = '' 47 - mv ae-${_d_ae_ver} "ae" 48 - ''; 22 + buildInputs = [ 23 + ncurses 24 + zlib 25 + ]; 49 26 50 - 51 - nativeBuildInputs = [ dub ldc ]; 52 - buildInputs = [ ncurses zlib ]; 53 - 54 - configurePhase = '' 55 - runHook preConfigure 56 - mkdir home 57 - HOME="home" dub add-local ae ${_d_ae_ver} 58 - HOME="home" dub add-local d-btrfs-${_d_btrfs_ver} ${_d_btrfs_ver} 59 - HOME="home" dub add-local ncurses-${_d_ncurses_ver} ${_d_ncurses_ver} 60 - HOME="home" dub add-local containers-${_d_emsi_containers_ver} ${_d_emsi_containers_ver} 61 - runHook postConfigure 62 - ''; 27 + installPhase = '' 28 + runHook preInstall 29 + install -Dm755 btdu -t $out/bin 30 + runHook postInstall 31 + ''; 63 32 64 - buildPhase = '' 65 - runHook preBuild 66 - cd ${pname}-${version} 67 - HOME="../home" dub --skip-registry=all build -b release 68 - runHook postBuild 69 - ''; 70 - 71 - installPhase = '' 72 - runHook preInstall 73 - mkdir -p $out/bin 74 - cp btdu $out/bin/ 75 - runHook postInstall 76 - ''; 77 - 78 - postInstall = '' 79 - ${removeReferencesTo}/bin/remove-references-to -t ${ldc} $out/bin/btdu 80 - ''; 81 - 82 - passthru.updateScript = ./update.py; 83 - 84 - meta = with lib; { 85 - description = "Sampling disk usage profiler for btrfs"; 86 - homepage = "https://github.com/CyberShadow/btdu"; 87 - changelog = "https://github.com/CyberShadow/btdu/releases/tag/v${version}"; 88 - license = licenses.gpl2Only; 89 - platforms = platforms.linux; 90 - maintainers = with maintainers; [ atila ]; 91 - mainProgram = "btdu"; 92 - }; 33 + meta = with lib; { 34 + description = "Sampling disk usage profiler for btrfs"; 35 + homepage = "https://github.com/CyberShadow/btdu"; 36 + changelog = "https://github.com/CyberShadow/btdu/releases/tag/${src.rev}"; 37 + license = licenses.gpl2Only; 38 + platforms = platforms.linux; 39 + maintainers = with maintainers; [ atila ]; 40 + mainProgram = "btdu"; 41 + }; 93 42 }
+20
pkgs/tools/misc/btdu/dub-lock.json
··· 1 + { 2 + "dependencies": { 3 + "ae": { 4 + "version": "0.0.3236", 5 + "sha256": "0by9yclvk795nw7ilwhv7wh17j2dd7xk54phs8s5jxrwpqx10x52" 6 + }, 7 + "btrfs": { 8 + "version": "0.0.18", 9 + "sha256": "0m8r4skfiryn2nk4wyb61lpvlga1330crr4y1h0q39g9xl3g6myf" 10 + }, 11 + "ncurses": { 12 + "version": "1.0.0", 13 + "sha256": "0ivl88vp2dy9rpv6x3f9jlyqa7aps2x1kkyx80w2d4vcs31pzmb2" 14 + }, 15 + "emsi_containers": { 16 + "version": "0.9.0", 17 + "sha256": "1viz1fjh6jhfvl0d25bb1q7aclm1hrs0d7hhcx1d9c0gg5k6lcpm" 18 + } 19 + } 20 + }
-82
pkgs/tools/misc/btdu/update.py
··· 1 - #!/usr/bin/env nix-shell 2 - #!nix-shell -i python -p python39Packages.requests 3 - 4 - import requests 5 - import subprocess 6 - 7 - pkgbuild = requests.get('https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=btdu').text 8 - 9 - def grabDepVersions(depDict, pkgbuild=pkgbuild): 10 - for line in pkgbuild.split('\n'): 11 - if depDict["string"] in line: 12 - start = len(depDict["string"]) + 1 13 - depDict["version"] = line[start:] 14 - break 15 - 16 - def grabDepHashes(key,pkgbuild=pkgbuild): 17 - start = pkgbuild.find(key) + len(key) 18 - end = start+64 19 - hashes = [] 20 - for i in range(5): 21 - hashes.append(pkgbuild[start:end]) 22 - start = pkgbuild.find("'",end+1) + 1 23 - end = start+64 24 - return hashes 25 - 26 - def findLine(key,derivation): 27 - count = 0 28 - lines = [] 29 - for line in derivation: 30 - if key in line: 31 - lines.append(count) 32 - count += 1 33 - return lines 34 - 35 - def updateVersions(btdu,ae,btrfs,ncurses,containers,derivation): 36 - key = "let" 37 - line = findLine(key,derivation)[0] + 1 38 - derivation[line+0] = f' _d_ae_ver = "{ae["version"]}";\n' 39 - derivation[line+1] = f' _d_btrfs_ver = "{btrfs["version"]}";\n' 40 - derivation[line+2] = f' _d_ncurses_ver = "{ncurses["version"]}";\n' 41 - derivation[line+3] = f' _d_emsi_containers_ver = "{containers["version"]}";\n' 42 - 43 - key = "version = " 44 - line = findLine(key,derivation)[0] 45 - derivation[line] = f' version = "{btdu["version"]}";\n' 46 - 47 - return derivation 48 - 49 - def updateHashes(btdu,ae,btrfs,ncurses,containers,derivation): 50 - key = "sha256 = " 51 - hashLines = findLine(key,derivation) 52 - for i in range(len(hashes)): 53 - derivation[hashLines[i]] = f' sha256 = "{hashes[i]}";\n' 54 - 55 - return derivation 56 - 57 - if __name__ == "__main__": 58 - 59 - btdu = {"string": "pkgver"} 60 - ae = {"string": "_d_ae_ver"} 61 - btrfs = {"string": "_d_btrfs_ver"} 62 - ncurses = {"string": "_d_ncurses_ver"} 63 - containers = {"string": "_d_emsi_containers_ver"} 64 - 65 - grabDepVersions(btdu) 66 - grabDepVersions(ae) 67 - grabDepVersions(btrfs) 68 - grabDepVersions(ncurses) 69 - grabDepVersions(containers) 70 - 71 - hashes = grabDepHashes("sha256sums=('") 72 - 73 - nixpkgs = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip('\n') 74 - btduFolder = "/pkgs/tools/misc/btdu/" 75 - with open(nixpkgs + btduFolder + "default.nix", 'r') as arq: 76 - derivation = arq.readlines() 77 - 78 - derivation = updateVersions(btdu,ae,btrfs,ncurses,containers,derivation) 79 - derivation = updateHashes(btdu,ae,btrfs,ncurses,containers,derivation) 80 - 81 - with open(nixpkgs + btduFolder + "default.nix", 'w') as arq: 82 - arq.writelines(derivation)
+3
pkgs/top-level/all-packages.nix
··· 7553 7553 7554 7554 dub = callPackage ../development/tools/build-managers/dub { }; 7555 7555 7556 + inherit (import ../build-support/dlang/dub-support.nix { inherit callPackage; }) 7557 + buildDubPackage dub-to-nix; 7558 + 7556 7559 duc = callPackage ../tools/misc/duc { }; 7557 7560 7558 7561 duff = callPackage ../tools/filesystems/duff {