forked from tupakkatapa/mozid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
77 lines (72 loc) · 2.3 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
description = "Nix tools for retrieving Mozilla add-on IDs.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
mozid-name = "mozid";
mozid-dependencies = with pkgs; [
curl
gnugrep
unzip
];
mozid-package = pkgs.symlinkJoin {
name = mozid-name;
paths = [
(pkgs.writeShellScriptBin mozid-name (builtins.readFile ./mozid.sh))
] ++ mozid-dependencies;
buildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/${mozid-name} --prefix PATH : $out/bin";
};
mozid-wrapper =
name: arg:
let
mozid-name-name = "${mozid-name}-${name}";
in
builtins.toString (
pkgs.writeShellScriptBin mozid-name-name ''
${mozid-package}/bin/${mozid-name} ${arg} $@
''
)
+ "/bin/"
+ mozid-name-name;
in
{
# Publish script with dependencies as package.
packages.mozid = mozid-package;
# For every default '$base_url' created a wrapped derivation as app.
apps = {
mozid-firefox = {
type = "app";
program = mozid-wrapper "firefox" "https://addons.mozilla.org/firefox/downloads/file";
};
mozid-thunderbird = {
type = "app";
program = mozid-wrapper "thunderbird" "https://addons.thunderbird.net/thunderbird/downloads/latest";
};
};
# Just for fun, made it into a non-functional library function (because of sandbox).
lib.mozid =
base: extension:
builtins.readFile ''${pkgs.runCommand "lib${mozid-name}" {
buildInputs = mozid-dependencies;
env = {
inherit base extension;
};
} "echo -n `${mozid-package}/bin/${mozid-name} @$base @$extension` > $out"}'';
# For developing the 'mozid.sh' script.
devShells.default = pkgs.mkShell { buildInputs = mozid-dependencies; };
}
);
}