mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
Merge pull request #299618 from TomaSajt/dub-support
Add buildDubPackage and dub-to-nix for building dub based packages
This commit is contained in:
commit
b136700c7d
69
doc/languages-frameworks/dlang.section.md
Normal file
69
doc/languages-frameworks/dlang.section.md
Normal file
@ -0,0 +1,69 @@
|
||||
# D (Dlang) {#dlang}
|
||||
|
||||
Nixpkgs provides multiple D compilers such as `ldc`, `dmd` and `gdc`.
|
||||
These can be used like any other package during build time.
|
||||
|
||||
However, Nixpkgs provides a build helper for compiling packages using the `dub` package manager.
|
||||
|
||||
Here's an example:
|
||||
```nix
|
||||
{
|
||||
lib,
|
||||
buildDubPackage,
|
||||
fetchFromGitHub,
|
||||
ncurses,
|
||||
zlib,
|
||||
}:
|
||||
|
||||
buildDubPackage rec {
|
||||
pname = "btdu";
|
||||
version = "0.5.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "CyberShadow";
|
||||
repo = "btdu";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE=";
|
||||
};
|
||||
|
||||
# generated by dub-to-nix, see below
|
||||
dubLock = ./dub-lock.json;
|
||||
|
||||
buildInputs = [
|
||||
ncurses
|
||||
zlib
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 btdu -t $out/bin
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
Note that you need to define `installPhase` because `dub` doesn't know where files should go in `$out`.
|
||||
|
||||
Also note that running `dub test` is disabled by default. You can enable it by setting `doCheck = true`.
|
||||
|
||||
## Lockfiles {#dub-lockfiles}
|
||||
Nixpkgs has its own lockfile format for `dub` dependencies, because `dub`'s official "lockfile" format (`dub.selections.json`) is not hash based.
|
||||
|
||||
A lockfile can be generated using the `dub-to-nix` helper package.
|
||||
* Firstly, install `dub-to-nix` into your shell session by running `nix-shell -p dub-to-nix`
|
||||
* Then navigate to the root of the source of the program you want to package
|
||||
* 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.
|
||||
|
||||
## `buildDubPackage` parameters {#builddubpackage-parameters}
|
||||
|
||||
The `buildDubPackage` function takes an attrset of parameters that are passed on to `stdenv.mkDerivation`.
|
||||
|
||||
The following parameters are specific to `buildDubPackage`:
|
||||
|
||||
* `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`.
|
||||
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)
|
||||
* `dubBuildType ? "release"`: The build type to pass to `dub build` as a value for the `--build=` flag.
|
||||
* `dubFlags ? []`: The flags to pass to `dub build` and `dub test`.
|
||||
* `dubBuildFlags ? []`: The flags to pass to `dub build`.
|
||||
* `dubTestFlags ? []`: The flags to pass to `dub test`.
|
||||
* `compiler ? ldc`: The D compiler to be used by `dub`.
|
@ -14,6 +14,7 @@ cuda.section.md
|
||||
cuelang.section.md
|
||||
dart.section.md
|
||||
dhall.section.md
|
||||
dlang.section.md
|
||||
dotnet.section.md
|
||||
emscripten.section.md
|
||||
gnome.section.md
|
||||
|
@ -402,6 +402,9 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
|
||||
The `nimPackages` and `nim2Packages` sets have been removed.
|
||||
See https://nixos.org/manual/nixpkgs/unstable#nim for more information.
|
||||
|
||||
- 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.
|
||||
See the [D section](https://nixos.org/manual/nixpkgs/unstable#dlang) in the manual for more information.
|
||||
|
||||
- [Portunus](https://github.com/majewsky/portunus) has been updated to major version 2.
|
||||
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.
|
||||
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
Normal file
7
pkgs/build-support/dlang/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Build support for D
|
||||
|
||||
Build utilities for the D language can be found in this directory.
|
||||
|
||||
### Current maintainers
|
||||
- @TomaSajt
|
||||
- @jtbx
|
124
pkgs/build-support/dlang/builddubpackage/default.nix
Normal file
124
pkgs/build-support/dlang/builddubpackage/default.nix
Normal file
@ -0,0 +1,124 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
linkFarm,
|
||||
dub,
|
||||
ldc,
|
||||
removeReferencesTo,
|
||||
}:
|
||||
|
||||
# See https://nixos.org/manual/nixpkgs/unstable#dlang for more detailed usage information
|
||||
|
||||
{
|
||||
# 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`.
|
||||
dubLock,
|
||||
# The build type to pass to `dub build` as a value for the `--build=` flag.
|
||||
dubBuildType ? "release",
|
||||
# The flags to pass to `dub build` and `dub test`.
|
||||
dubFlags ? [ ],
|
||||
# The flags to pass to `dub build`.
|
||||
dubBuildFlags ? [ ],
|
||||
# The flags to pass to `dub test`.
|
||||
dubTestFlags ? [ ],
|
||||
# The D compiler to be used by `dub`.
|
||||
compiler ? ldc,
|
||||
...
|
||||
}@args:
|
||||
|
||||
let
|
||||
makeDubDep =
|
||||
{
|
||||
pname,
|
||||
version,
|
||||
sha256,
|
||||
}:
|
||||
{
|
||||
inherit pname version;
|
||||
src = fetchurl {
|
||||
name = "dub-${pname}-${version}.zip";
|
||||
url = "mirror://dub/${pname}/${version}.zip";
|
||||
inherit sha256;
|
||||
};
|
||||
};
|
||||
|
||||
lockJson = if lib.isPath dubLock then lib.importJSON dubLock else dubLock;
|
||||
|
||||
lockedDeps = lib.mapAttrsToList (
|
||||
pname: { version, sha256 }: makeDubDep { inherit pname version sha256; }
|
||||
) lockJson.dependencies;
|
||||
|
||||
# a directory with multiple single element registries
|
||||
# one big directory with all .zip files leads to version parsing errors
|
||||
# when the name of a package is a prefix of the name of another package
|
||||
dubRegistryBase = linkFarm "dub-registry-base" (
|
||||
map (dep: {
|
||||
name = "${dep.pname}/${dep.pname}-${dep.version}.zip";
|
||||
path = dep.src;
|
||||
}) lockedDeps
|
||||
);
|
||||
|
||||
combinedFlags = "--skip-registry=all --compiler=${lib.getExe compiler} ${toString dubFlags}";
|
||||
combinedBuildFlags = "${combinedFlags} --build=${dubBuildType} ${toString dubBuildFlags}";
|
||||
combinedTestFlags = "${combinedFlags} ${toString dubTestFlags}";
|
||||
in
|
||||
stdenv.mkDerivation (
|
||||
builtins.removeAttrs args [ "dubLock" ]
|
||||
// {
|
||||
strictDeps = args.strictDeps or true;
|
||||
|
||||
nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
|
||||
dub
|
||||
compiler
|
||||
removeReferencesTo
|
||||
];
|
||||
|
||||
configurePhase =
|
||||
args.configurePhase or ''
|
||||
runHook preConfigure
|
||||
|
||||
export DUB_HOME="$NIX_BUILD_TOP/.dub"
|
||||
mkdir -p $DUB_HOME
|
||||
|
||||
# register dependencies
|
||||
${lib.concatMapStringsSep "\n" (dep: ''
|
||||
dub fetch ${dep.pname}@${dep.version} --cache=user --skip-registry=standard --registry=file://${dubRegistryBase}/${dep.pname}
|
||||
'') lockedDeps}
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase =
|
||||
args.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
dub build ${combinedBuildFlags}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
doCheck = args.doCheck or false;
|
||||
|
||||
checkPhase =
|
||||
args.checkPhase or ''
|
||||
runHook preCheck
|
||||
|
||||
dub test ${combinedTestFlags}
|
||||
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
${args.preFixup or ""}
|
||||
|
||||
find "$out" -type f -exec remove-references-to -t ${compiler} '{}' +
|
||||
'';
|
||||
|
||||
disallowedReferences = [ compiler ];
|
||||
|
||||
meta = {
|
||||
platforms = dub.meta.platforms;
|
||||
} // args.meta or { };
|
||||
}
|
||||
)
|
5
pkgs/build-support/dlang/dub-support.nix
Normal file
5
pkgs/build-support/dlang/dub-support.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ callPackage }:
|
||||
{
|
||||
buildDubPackage = callPackage ./builddubpackage { };
|
||||
dub-to-nix = callPackage ./dub-to-nix { };
|
||||
}
|
19
pkgs/build-support/dlang/dub-to-nix/default.nix
Normal file
19
pkgs/build-support/dlang/dub-to-nix/default.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
lib,
|
||||
runCommand,
|
||||
makeWrapper,
|
||||
python3,
|
||||
nix,
|
||||
}:
|
||||
|
||||
runCommand "dub-to-nix"
|
||||
{
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ python3 ];
|
||||
}
|
||||
''
|
||||
install -Dm755 ${./dub-to-nix.py} "$out/bin/dub-to-nix"
|
||||
patchShebangs "$out/bin/dub-to-nix"
|
||||
wrapProgram "$out/bin/dub-to-nix" \
|
||||
--prefix PATH : ${lib.makeBinPath [ nix ]}
|
||||
''
|
39
pkgs/build-support/dlang/dub-to-nix/dub-to-nix.py
Normal file
39
pkgs/build-support/dlang/dub-to-nix/dub-to-nix.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
def eprint(text: str):
|
||||
print(text, file=sys.stderr)
|
||||
|
||||
if not os.path.exists("dub.selections.json"):
|
||||
eprint("The file `dub.selections.json` does not exist in the current working directory")
|
||||
eprint("run `dub upgrade --annotate` to generate it")
|
||||
sys.exit(1)
|
||||
|
||||
with open("dub.selections.json") as f:
|
||||
selectionsJson = json.load(f)
|
||||
|
||||
versionDict: dict[str, str] = selectionsJson["versions"]
|
||||
|
||||
for pname in versionDict:
|
||||
version = versionDict[pname]
|
||||
if version.startswith("~"):
|
||||
eprint(f'Package "{pname}" has a branch-type version "{version}", which doesn\'t point to a fixed version')
|
||||
eprint("You can resolve it by manually changing the required version to a fixed one inside `dub.selections.json`")
|
||||
eprint("When packaging, you might need to create a patch for `dub.sdl` or `dub.json` to accept the changed version")
|
||||
sys.exit(1)
|
||||
|
||||
lockedDependenciesDict: dict[str, dict[str, str]] = {}
|
||||
|
||||
for pname in versionDict:
|
||||
version = versionDict[pname]
|
||||
eprint(f"Fetching {pname}@{version}")
|
||||
url = f"https://code.dlang.org/packages/{pname}/{version}.zip"
|
||||
command = ["nix-prefetch-url", "--type", "sha256", url]
|
||||
sha256 = subprocess.run(command, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.rstrip()
|
||||
lockedDependenciesDict[pname] = {"version": version, "sha256": sha256}
|
||||
|
||||
print(json.dumps({"dependencies": lockedDependenciesDict}, indent=2))
|
@ -312,6 +312,11 @@
|
||||
"https://backpan.perl.org/" # for old releases
|
||||
];
|
||||
|
||||
# D DUB
|
||||
dub = [
|
||||
"https://code.dlang.org/packages/"
|
||||
];
|
||||
|
||||
# Haskell Hackage
|
||||
hackage = [
|
||||
"https://hackage.haskell.org/package/"
|
||||
|
112
pkgs/by-name/se/serve-d/dub-lock.json
Normal file
112
pkgs/by-name/se/serve-d/dub-lock.json
Normal file
@ -0,0 +1,112 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"automem": {
|
||||
"version": "0.6.9",
|
||||
"sha256": "05zk8h81ih5jc4n8d7kgr6hv5f923ybf2pdyf2ld3imkx0zb0plr"
|
||||
},
|
||||
"cachetools": {
|
||||
"version": "0.4.1",
|
||||
"sha256": "1407cb3mm8pqlcljdi60lpz2vhsj6rwzax0j24xggmyhr7ij6gx7"
|
||||
},
|
||||
"dcd": {
|
||||
"version": "0.13.6",
|
||||
"sha256": "19fnp5hdk2n7z5s57a445a92xd4iadh7lbw14sq1pr4zyks32114"
|
||||
},
|
||||
"dfmt": {
|
||||
"version": "0.14.1",
|
||||
"sha256": "1czk48dylq05iwi9137hy694c43whiqnmvgc5k7c32bjzzpi5pyq"
|
||||
},
|
||||
"diet-complete": {
|
||||
"version": "0.0.3",
|
||||
"sha256": "1klzivhzb185m38jvmm957s38mllpa2rkkv8az8ipmwdjj8z6mpv"
|
||||
},
|
||||
"dscanner": {
|
||||
"version": "0.12.2",
|
||||
"sha256": "12zhby1vj28fsryv7j6xhdiiw8d7dk1d00sarpimfpl77ajmpia8"
|
||||
},
|
||||
"dsymbol": {
|
||||
"version": "0.11.3",
|
||||
"sha256": "0flnh8b1hc97hlm86ilb0kc194vib5cpqf8abxfbv24czxp6gfv7"
|
||||
},
|
||||
"dub": {
|
||||
"version": "1.26.1",
|
||||
"sha256": "0sbixp7dpixlp1hwjlmnlh4dwci9f2fadxg42j8ha86rx7ggprqi"
|
||||
},
|
||||
"dunit": {
|
||||
"version": "1.0.16",
|
||||
"sha256": "0p9g4h5qanbg6281x1068mdl5p7zvqig4zmmi72a2cay6dxnbvxb"
|
||||
},
|
||||
"emsi_containers": {
|
||||
"version": "0.8.0",
|
||||
"sha256": "032j0rrlnhx0z2xrg9pfhb1darzj4h8qvxhixiw8gwz5izaxq1ny"
|
||||
},
|
||||
"eventsystem": {
|
||||
"version": "1.2.0",
|
||||
"sha256": "0spg6p8rxihdn473pmwxghbkkzzccamkqxdcqaqf6k06zvjl7qfs"
|
||||
},
|
||||
"inifiled": {
|
||||
"version": "1.3.3",
|
||||
"sha256": "01hw0lb9n6vwmx6vj5nq2awg54l5pvngqhzxfj2kmg99az84dg6d"
|
||||
},
|
||||
"isfreedesktop": {
|
||||
"version": "0.1.1",
|
||||
"sha256": "0bnjr9avvhl7s09dnbcdr5437yb18jj26fzvm7j292kvd2i8kzqz"
|
||||
},
|
||||
"libddoc": {
|
||||
"version": "0.7.4",
|
||||
"sha256": "1cs4nycn0pl30354dccb2akmbcdmz22yq28sn3imvfndmh059szi"
|
||||
},
|
||||
"libdparse": {
|
||||
"version": "0.19.4",
|
||||
"sha256": "1nyhga4qxkkf1qs3sd07mnyifw81dbz3nwm1vj106kair0d25q0b"
|
||||
},
|
||||
"msgpack-d": {
|
||||
"version": "1.0.1",
|
||||
"sha256": "1b6v667ymns90n0ssg7bd8fny1ashv5axpa8xf461ghzqnkkh05d"
|
||||
},
|
||||
"painlessjson": {
|
||||
"version": "1.4.0",
|
||||
"sha256": "0gy71wbssgn7z50gy8fg3mmwk82qp3y17ypl3x10jbc9nczipryi"
|
||||
},
|
||||
"painlesstraits": {
|
||||
"version": "0.3.0",
|
||||
"sha256": "0li4n0v70x5sgnqv60v5481jqlv22mk338cww4d3z5l0nhng3bvh"
|
||||
},
|
||||
"requests": {
|
||||
"version": "2.1.2",
|
||||
"sha256": "10332kdsjv30zkayx3vg6lxa701wmdncf0xjxwxkcjpsw7smzs2z"
|
||||
},
|
||||
"rm-rf": {
|
||||
"version": "0.1.0",
|
||||
"sha256": "0yr2jan7m49y0c6vm8nblvmgqqzw1c19g5m3cb412wwa37k12v5d"
|
||||
},
|
||||
"silly": {
|
||||
"version": "1.1.1",
|
||||
"sha256": "1l0mpnbz8h3ihjxvk5qwn6p6lwb75g259k7fjqasw0zp0c27bkjb"
|
||||
},
|
||||
"standardpaths": {
|
||||
"version": "0.8.1",
|
||||
"sha256": "026sy2ywi708s3kx6ca55nkbq1hn3bcj9804bf01dvxnlschmlvc"
|
||||
},
|
||||
"stdx-allocator": {
|
||||
"version": "2.77.5",
|
||||
"sha256": "1g8382wr49sjyar0jay8j7y2if7h1i87dhapkgxphnizp24d7kaj"
|
||||
},
|
||||
"test_allocator": {
|
||||
"version": "0.3.4",
|
||||
"sha256": "1xpjz6smxwgm4walrv3xbzi46cddc80q5n4gs7j9gm2yx11sf7gj"
|
||||
},
|
||||
"unit-threaded": {
|
||||
"version": "0.10.8",
|
||||
"sha256": "1jvmxka6s2zzrxns62jb50p01bgybhbkrkgi9qzq93xldc6jn2i9"
|
||||
},
|
||||
"workspace-d": {
|
||||
"version": "3.7.0",
|
||||
"sha256": "0alhmb64v7sbm1g9pdsng3fqy941s67lsqxjcf8awg1z7kn3l1hv"
|
||||
},
|
||||
"xdgpaths": {
|
||||
"version": "0.2.5",
|
||||
"sha256": "09l3bkcldv7ckh3d2cmivvj3cbql96a24g3khlz7zp9f1aabfykl"
|
||||
}
|
||||
}
|
||||
}
|
39
pkgs/by-name/se/serve-d/package.nix
Normal file
39
pkgs/by-name/se/serve-d/package.nix
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
lib,
|
||||
buildDubPackage,
|
||||
fetchFromGitHub,
|
||||
dtools,
|
||||
}:
|
||||
|
||||
buildDubPackage rec {
|
||||
pname = "serve-d";
|
||||
version = "0.7.6";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Pure-D";
|
||||
repo = "serve-d";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-h4zsW8phGcI4z0uMCIovM9cJ6hKdk8rLb/Jp4X4dkpk=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ dtools ];
|
||||
|
||||
dubLock = ./dub-lock.json;
|
||||
|
||||
doCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 serve-d -t $out/bin
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
changelog = "https://github.com/Pure-D/serve-d/releases/tag/${src.rev}";
|
||||
description = "D LSP server (dlang language server protocol server)";
|
||||
homepage = "https://github.com/Pure-D/serve-d";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "serve-d";
|
||||
maintainers = with lib.maintainers; [ tomasajt ];
|
||||
};
|
||||
}
|
@ -130,6 +130,7 @@ stdenv.mkDerivation rec {
|
||||
homepage = "https://github.com/ldc-developers/ldc";
|
||||
# from https://github.com/ldc-developers/ldc/blob/master/LICENSE
|
||||
license = with licenses; [ bsd3 boost mit ncsa gpl2Plus ];
|
||||
mainProgram = "ldc2";
|
||||
maintainers = with maintainers; [ lionello jtbx ];
|
||||
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
};
|
||||
|
@ -1,6 +1,10 @@
|
||||
{ lib, stdenv, fetchFromGitHub, ldc, dub }:
|
||||
{
|
||||
lib,
|
||||
buildDubPackage,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
buildDubPackage {
|
||||
pname = "Literate";
|
||||
version = "unstable-2021-01-22";
|
||||
|
||||
@ -8,21 +12,29 @@ stdenv.mkDerivation {
|
||||
owner = "zyedidia";
|
||||
repo = "Literate";
|
||||
rev = "7004dffec0cff3068828514eca72172274fd3f7d";
|
||||
sha256 = "sha256-erNFe0+FlrslEENyO/YxYQbmec0voK31UWr5qVt+nXQ=";
|
||||
hash = "sha256-erNFe0+FlrslEENyO/YxYQbmec0voK31UWr5qVt+nXQ=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
buildInputs = [ ldc dub ];
|
||||
# as there aren't any non-local dub dependencies, this file just has any empty list
|
||||
dubLock = ./dub-lock.json;
|
||||
|
||||
HOME = "home";
|
||||
# generate the actual .d source files defined in .lit files
|
||||
preBuild = ''
|
||||
make d-files
|
||||
'';
|
||||
|
||||
installPhase = "install -D bin/lit $out/bin/lit";
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 bin/lit -t $out/bin
|
||||
runHook preInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
meta = {
|
||||
description = "A literate programming tool for any language";
|
||||
homepage = "https://zyedidia.github.io/literate/";
|
||||
license = licenses.mit;
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "lit";
|
||||
platforms = platforms.unix;
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"dependencies": {}
|
||||
}
|
@ -1,93 +1,42 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, dub
|
||||
, ncurses
|
||||
, ldc
|
||||
, zlib
|
||||
, removeReferencesTo
|
||||
{
|
||||
lib,
|
||||
buildDubPackage,
|
||||
fetchFromGitHub,
|
||||
ncurses,
|
||||
zlib,
|
||||
}:
|
||||
|
||||
let
|
||||
_d_ae_ver = "0.0.3236";
|
||||
_d_btrfs_ver = "0.0.18";
|
||||
_d_ncurses_ver = "1.0.0";
|
||||
_d_emsi_containers_ver = "0.9.0";
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "btdu";
|
||||
version = "0.5.1";
|
||||
buildDubPackage rec {
|
||||
pname = "btdu";
|
||||
version = "0.5.1";
|
||||
|
||||
srcs = [
|
||||
(fetchurl {
|
||||
url = "https://github.com/CyberShadow/${pname}/archive/v${version}.tar.gz";
|
||||
sha256 = "566269f365811f6db53280fc5476a7fcf34791396ee4e090c150af4280b35ba5";
|
||||
})
|
||||
(fetchurl {
|
||||
url = "https://github.com/CyberShadow/ae/archive/v${_d_ae_ver}.tar.gz";
|
||||
sha256 = "5ea3f0d9d2d13012ce6a1ee1b52d9fdff9dfb1d5cc7ee5d1b04cab1947ed4d36";
|
||||
})
|
||||
(fetchurl {
|
||||
url = "https://github.com/CyberShadow/d-btrfs/archive/v${_d_btrfs_ver}.tar.gz";
|
||||
sha256 = "32af4891d93c7898b0596eefb8297b88d3ed5c14c84a5951943b7b54c7599dbd";
|
||||
})
|
||||
(fetchurl {
|
||||
url = "https://github.com/D-Programming-Deimos/ncurses/archive/v${_d_ncurses_ver}.tar.gz";
|
||||
sha256 = "b5db677b75ebef7a1365ca4ef768f7344a2bc8d07ec223a2ada162f185d0d9c6";
|
||||
})
|
||||
(fetchurl {
|
||||
url = "https://github.com/dlang-community/containers/archive/v${_d_emsi_containers_ver}.tar.gz";
|
||||
sha256 = "5e256b84bbdbd2bd625cba0472ea27a1fde6d673d37a85fe971a20d52874acaa";
|
||||
})
|
||||
];
|
||||
src = fetchFromGitHub {
|
||||
owner = "CyberShadow";
|
||||
repo = "btdu";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-3sSZq+5UJH02IO0Y1yL3BLHDb4lk8k6awb5ZysBQciE=";
|
||||
};
|
||||
|
||||
sourceRoot = ".";
|
||||
dubLock = ./dub-lock.json;
|
||||
|
||||
postUnpack = ''
|
||||
mv ae-${_d_ae_ver} "ae"
|
||||
'';
|
||||
buildInputs = [
|
||||
ncurses
|
||||
zlib
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 btdu -t $out/bin
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ dub ldc ];
|
||||
buildInputs = [ ncurses zlib ];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
mkdir home
|
||||
HOME="home" dub add-local ae ${_d_ae_ver}
|
||||
HOME="home" dub add-local d-btrfs-${_d_btrfs_ver} ${_d_btrfs_ver}
|
||||
HOME="home" dub add-local ncurses-${_d_ncurses_ver} ${_d_ncurses_ver}
|
||||
HOME="home" dub add-local containers-${_d_emsi_containers_ver} ${_d_emsi_containers_ver}
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
cd ${pname}-${version}
|
||||
HOME="../home" dub --skip-registry=all build -b release
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
cp btdu $out/bin/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${ldc} $out/bin/btdu
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.py;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Sampling disk usage profiler for btrfs";
|
||||
homepage = "https://github.com/CyberShadow/btdu";
|
||||
changelog = "https://github.com/CyberShadow/btdu/releases/tag/v${version}";
|
||||
license = licenses.gpl2Only;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ atila ];
|
||||
mainProgram = "btdu";
|
||||
};
|
||||
meta = with lib; {
|
||||
description = "Sampling disk usage profiler for btrfs";
|
||||
homepage = "https://github.com/CyberShadow/btdu";
|
||||
changelog = "https://github.com/CyberShadow/btdu/releases/tag/${src.rev}";
|
||||
license = licenses.gpl2Only;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ atila ];
|
||||
mainProgram = "btdu";
|
||||
};
|
||||
}
|
||||
|
20
pkgs/tools/misc/btdu/dub-lock.json
Normal file
20
pkgs/tools/misc/btdu/dub-lock.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"ae": {
|
||||
"version": "0.0.3236",
|
||||
"sha256": "0by9yclvk795nw7ilwhv7wh17j2dd7xk54phs8s5jxrwpqx10x52"
|
||||
},
|
||||
"btrfs": {
|
||||
"version": "0.0.18",
|
||||
"sha256": "0m8r4skfiryn2nk4wyb61lpvlga1330crr4y1h0q39g9xl3g6myf"
|
||||
},
|
||||
"ncurses": {
|
||||
"version": "1.0.0",
|
||||
"sha256": "0ivl88vp2dy9rpv6x3f9jlyqa7aps2x1kkyx80w2d4vcs31pzmb2"
|
||||
},
|
||||
"emsi_containers": {
|
||||
"version": "0.9.0",
|
||||
"sha256": "1viz1fjh6jhfvl0d25bb1q7aclm1hrs0d7hhcx1d9c0gg5k6lcpm"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python -p python39Packages.requests
|
||||
|
||||
import requests
|
||||
import subprocess
|
||||
|
||||
pkgbuild = requests.get('https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=btdu').text
|
||||
|
||||
def grabDepVersions(depDict, pkgbuild=pkgbuild):
|
||||
for line in pkgbuild.split('\n'):
|
||||
if depDict["string"] in line:
|
||||
start = len(depDict["string"]) + 1
|
||||
depDict["version"] = line[start:]
|
||||
break
|
||||
|
||||
def grabDepHashes(key,pkgbuild=pkgbuild):
|
||||
start = pkgbuild.find(key) + len(key)
|
||||
end = start+64
|
||||
hashes = []
|
||||
for i in range(5):
|
||||
hashes.append(pkgbuild[start:end])
|
||||
start = pkgbuild.find("'",end+1) + 1
|
||||
end = start+64
|
||||
return hashes
|
||||
|
||||
def findLine(key,derivation):
|
||||
count = 0
|
||||
lines = []
|
||||
for line in derivation:
|
||||
if key in line:
|
||||
lines.append(count)
|
||||
count += 1
|
||||
return lines
|
||||
|
||||
def updateVersions(btdu,ae,btrfs,ncurses,containers,derivation):
|
||||
key = "let"
|
||||
line = findLine(key,derivation)[0] + 1
|
||||
derivation[line+0] = f' _d_ae_ver = "{ae["version"]}";\n'
|
||||
derivation[line+1] = f' _d_btrfs_ver = "{btrfs["version"]}";\n'
|
||||
derivation[line+2] = f' _d_ncurses_ver = "{ncurses["version"]}";\n'
|
||||
derivation[line+3] = f' _d_emsi_containers_ver = "{containers["version"]}";\n'
|
||||
|
||||
key = "version = "
|
||||
line = findLine(key,derivation)[0]
|
||||
derivation[line] = f' version = "{btdu["version"]}";\n'
|
||||
|
||||
return derivation
|
||||
|
||||
def updateHashes(btdu,ae,btrfs,ncurses,containers,derivation):
|
||||
key = "sha256 = "
|
||||
hashLines = findLine(key,derivation)
|
||||
for i in range(len(hashes)):
|
||||
derivation[hashLines[i]] = f' sha256 = "{hashes[i]}";\n'
|
||||
|
||||
return derivation
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
btdu = {"string": "pkgver"}
|
||||
ae = {"string": "_d_ae_ver"}
|
||||
btrfs = {"string": "_d_btrfs_ver"}
|
||||
ncurses = {"string": "_d_ncurses_ver"}
|
||||
containers = {"string": "_d_emsi_containers_ver"}
|
||||
|
||||
grabDepVersions(btdu)
|
||||
grabDepVersions(ae)
|
||||
grabDepVersions(btrfs)
|
||||
grabDepVersions(ncurses)
|
||||
grabDepVersions(containers)
|
||||
|
||||
hashes = grabDepHashes("sha256sums=('")
|
||||
|
||||
nixpkgs = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip('\n')
|
||||
btduFolder = "/pkgs/tools/misc/btdu/"
|
||||
with open(nixpkgs + btduFolder + "default.nix", 'r') as arq:
|
||||
derivation = arq.readlines()
|
||||
|
||||
derivation = updateVersions(btdu,ae,btrfs,ncurses,containers,derivation)
|
||||
derivation = updateHashes(btdu,ae,btrfs,ncurses,containers,derivation)
|
||||
|
||||
with open(nixpkgs + btduFolder + "default.nix", 'w') as arq:
|
||||
arq.writelines(derivation)
|
@ -7553,6 +7553,9 @@ with pkgs;
|
||||
|
||||
dub = callPackage ../development/tools/build-managers/dub { };
|
||||
|
||||
inherit (import ../build-support/dlang/dub-support.nix { inherit callPackage; })
|
||||
buildDubPackage dub-to-nix;
|
||||
|
||||
duc = callPackage ../tools/misc/duc { };
|
||||
|
||||
duff = callPackage ../tools/filesystems/duff {
|
||||
|
Loading…
Reference in New Issue
Block a user