base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ni / nix-plugin-pijul / package.nix
blobb9b7f62f01ba8807b23b3553f353ffe32db92160
2   lib,
3   stdenv,
4   fetchzip,
5   cmake,
6   pkg-config,
7   boost,
8   howard-hinnant-date,
10   # for tests
11   runCommand,
12   pijul,
13   nixVersions,
14   nixOverride ? null,
15   nix-plugin-pijul,
17 let nix = if nixOverride != null then nixOverride else nixVersions.nix_2_18;
18 in stdenv.mkDerivation (finalAttrs: {
19   pname = "nix-plugin-pijul";
20   version = "0.1.4";
22   src = fetchzip {
23     url = "https://dblsaiko.net/pub/nix-plugin-pijul/nix-plugin-pijul-${finalAttrs.version}.tar.gz";
24     hash = "sha256-X25tFqcAgNWmkMxbfXGx8KJ25BV6sFWAQM9NvjQeSmQ=";
25   };
27   nativeBuildInputs = [
28     cmake
29     pkg-config
30   ];
32   buildInputs = [
33     boost
34     howard-hinnant-date
35     nix
36   ];
38   passthru.tests = let
39     localRepoCheck = nixOverride:
40       runCommand "localRepoCheck-${nixOverride.name}"
41       {
42         nativeBuildInputs = [
43           pijul
44           nix
45         ];
46       }
47       ''
48         export HOME=$(mktemp -d)
49         export EDITOR=true
50         pijul identity new --no-link --no-prompt --display-name 'Test User' --email 'test@example.com'
52         pijul init repo
53         cd repo
55         echo "it works" > foo
56         pijul add foo
57         pijul record --message 'Add foo'
59         output=$(
60           nix \
61             --option plugin-files ${nix-plugin-pijul.override {inherit nixOverride;}}/lib/nix/plugins/pijul.so \
62             --extra-experimental-features 'nix-command flakes' \
63             eval --impure --raw --expr "builtins.readFile ((builtins.fetchTree \"pijul+file://$PWD\") + \"/foo\")"
64         )
66         echo $output
68         [[ "$output" = "it works" ]]
70         mkdir $out
71       '';
72   in {
73     stable = localRepoCheck nixVersions.stable;
74     latest = localRepoCheck nixVersions.latest;
75     git = localRepoCheck nixVersions.git;
76     nix_2_18 = localRepoCheck nixVersions.nix_2_18;
77     nix_2_19 = localRepoCheck nixVersions.nix_2_19;
78     nix_2_20 = localRepoCheck nixVersions.nix_2_20;
79     nix_2_21 = localRepoCheck nixVersions.nix_2_21;
80     nix_2_22 = localRepoCheck nixVersions.nix_2_22;
81     nix_2_23 = localRepoCheck nixVersions.nix_2_23;
82   };
84   meta = {
85     description = "Plugin to add Pijul support to the Nix package manager";
86     homepage = "https://nest.pijul.com/dblsaiko/nix-plugin-pijul";
87     license = lib.licenses.lgpl3Plus;
88     maintainers = [lib.maintainers.dblsaiko];
89     platforms = lib.platforms.unix;
90   };