summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-03-30 02:00:31 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-25 00:04:53 +0200
commita1cb06e4eb4145b810f8a9208ea25e596f40db9a (patch)
tree7ae2a016d26c6d6a4991687ba8289402243d9099
parentc88677f3a11a30d23ebccb2275352eadee484524 (diff)
downloadNUR-a1cb06e4eb4145b810f8a9208ea25e596f40db9a.tar.gz
NUR-a1cb06e4eb4145b810f8a9208ea25e596f40db9a.tar.zst
NUR-a1cb06e4eb4145b810f8a9208ea25e596f40db9a.zip
Bootstrap niv
-rw-r--r--default.nix3
-rw-r--r--environments/immae-eu.nix2
-rw-r--r--nix/README.md2
-rw-r--r--nix/sources.json53
-rw-r--r--nix/sources.nix135
-rw-r--r--pkgs/default.nix68
6 files changed, 228 insertions, 35 deletions
diff --git a/default.nix b/default.nix
index 3a4724bc..ec3b9d4a 100644
--- a/default.nix
+++ b/default.nix
@@ -1,5 +1,6 @@
1{ pkgs ? import <nixpkgs> {} }: 1{ sources ? import ./nix/sources.nix }:
2let 2let
3 pkgs = import sources.nixpkgs-env {};
3 pkgs_ = pkgs; 4 pkgs_ = pkgs;
4 mypkgs = import ./pkgs { pkgs = pkgs_; }; 5 mypkgs = import ./pkgs { pkgs = pkgs_; };
5in 6in
diff --git a/environments/immae-eu.nix b/environments/immae-eu.nix
index 8aec0363..de971c98 100644
--- a/environments/immae-eu.nix
+++ b/environments/immae-eu.nix
@@ -67,7 +67,7 @@ let
67 mylibs.yarn2nixPackage.yarn2nix nix 67 mylibs.yarn2nixPackage.yarn2nix nix
68 nixops nix-prefetch-scripts nix-generate-from-cpan 68 nixops nix-prefetch-scripts nix-generate-from-cpan
69 nix-zsh-completions bundix nodePackages.bower2nix 69 nix-zsh-completions bundix nodePackages.bower2nix
70 nodePackages.node2nix 70 nodePackages.node2nix niv
71 # (nixos {}).nixos-generate-config 71 # (nixos {}).nixos-generate-config
72 # (nixos {}).nixos-install 72 # (nixos {}).nixos-install
73 # (nixos {}).nixos-enter 73 # (nixos {}).nixos-enter
diff --git a/nix/README.md b/nix/README.md
new file mode 100644
index 00000000..7bf996c4
--- /dev/null
+++ b/nix/README.md
@@ -0,0 +1,2 @@
1This directory is handled by niv, but it prefers to have a directory
2named "nix"
diff --git a/nix/sources.json b/nix/sources.json
new file mode 100644
index 00000000..fb0e7d63
--- /dev/null
+++ b/nix/sources.json
@@ -0,0 +1,53 @@
1{
2 "niv": {
3 "branch": "master",
4 "description": "Easy dependency management for Nix projects",
5 "homepage": "https://github.com/nmattia/niv",
6 "owner": "nmattia",
7 "repo": "niv",
8 "rev": "372f96bff217a7a019de27667d04118cffa9841b",
9 "sha256": "1l0z6162zw60pdcdj03aq64qgf1vyzmf24i9pxca64i4sprl1b7p",
10 "type": "tarball",
11 "url": "https://github.com/nmattia/niv/archive/372f96bff217a7a019de27667d04118cffa9841b.tar.gz",
12 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13 },
14 "nixpkgs-env": {
15 "branch": "nixos-19.03",
16 "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
17 "homepage": "https://github.com/NixOS/nixpkgs",
18 "owner": "NixOS",
19 "repo": "nixpkgs-channels",
20 "rev": "34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59",
21 "sha256": "11z6ajj108fy2q5g8y4higlcaqncrbjm3dnv17pvif6avagw4mcb",
22 "type": "tarball",
23 "url": "https://github.com/NixOS/nixpkgs-channels/archive/34c7eb7545d155cc5b6f499b23a7cb1c96ab4d59.tar.gz",
24 "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25 },
26 "nixpkgs-nixops": {
27 "channel_link": "https://nixos.org/channels/nixos-19.03",
28 "revision": "173677.daf861a810d",
29 "sha256": "0v5bhdiyg1xv1dzsy7jbm301ighsvmi87wibw96iiky8sqs6qd4z",
30 "type": "tarball",
31 "url": "https://releases.nixos.org/nixos/19.03/nixos-19.03.173677.daf861a810d/nixexprs.tar.xz",
32 "url_template": "https://releases.nixos.org/nixos/<version>/nixos-<version>.<revision>/nixexprs.tar.xz",
33 "version": "19.03"
34 },
35 "nixpkgs-nixops-previous": {
36 "channel_link": "https://nixos.org/channels/nixos-19.03",
37 "revision": "173677.daf861a810d",
38 "sha256": "0v5bhdiyg1xv1dzsy7jbm301ighsvmi87wibw96iiky8sqs6qd4z",
39 "type": "tarball",
40 "url": "https://releases.nixos.org/nixos/19.03/nixos-19.03.173677.daf861a810d/nixexprs.tar.xz",
41 "url_template": "https://releases.nixos.org/nixos/<version>/nixos-<version>.<revision>/nixexprs.tar.xz",
42 "version": "19.03"
43 },
44 "nixpkgs-nixops-next": {
45 "channel_link": "https://nixos.org/channels/nixos-19.03",
46 "revision": "173677.daf861a810d",
47 "sha256": "0v5bhdiyg1xv1dzsy7jbm301ighsvmi87wibw96iiky8sqs6qd4z",
48 "type": "tarball",
49 "url": "https://releases.nixos.org/nixos/19.03/nixos-19.03.173677.daf861a810d/nixexprs.tar.xz",
50 "url_template": "https://releases.nixos.org/nixos/<version>/nixos-<version>.<revision>/nixexprs.tar.xz",
51 "version": "19.03"
52 }
53}
diff --git a/nix/sources.nix b/nix/sources.nix
new file mode 100644
index 00000000..45c97d10
--- /dev/null
+++ b/nix/sources.nix
@@ -0,0 +1,135 @@
1# This file has been generated by Niv.
2
3let
4
5 #
6 # The fetchers. fetch_<type> fetches specs of type <type>.
7 #
8
9 fetch_file = pkgs: spec:
10 if spec.builtin or true then
11 builtins_fetchurl { inherit (spec) url sha256; }
12 else
13 pkgs.fetchurl { inherit (spec) url sha256; };
14
15 fetch_tarball = pkgs: name: spec:
16 let
17 ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
18 # sanitize the name, though nix will still fail if name starts with period
19 name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
20 in
21 if spec.builtin or true then
22 builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
23 else
24 pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
25
26 fetch_git = spec:
27 builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
28
29 fetch_builtin-tarball = name: throw
30 ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
31 $ niv modify ${name} -a type=tarball -a builtin=true'';
32
33 fetch_builtin-url = name: throw
34 ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
35 $ niv modify ${name} -a type=file -a builtin=true'';
36
37 #
38 # Various helpers
39 #
40
41 # The set of packages used when specs are fetched using non-builtins.
42 mkPkgs = sources:
43 let
44 sourcesNixpkgs =
45 import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
46 hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
47 hasThisAsNixpkgsPath = <nixpkgs> == ./.;
48 in
49 if builtins.hasAttr "nixpkgs" sources
50 then sourcesNixpkgs
51 else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
52 import <nixpkgs> {}
53 else
54 abort
55 ''
56 Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
57 add a package called "nixpkgs" to your sources.json.
58 '';
59
60 # The actual fetching function.
61 fetch = pkgs: name: spec:
62
63 if ! builtins.hasAttr "type" spec then
64 abort "ERROR: niv spec ${name} does not have a 'type' attribute"
65 else if spec.type == "file" then fetch_file pkgs spec
66 else if spec.type == "tarball" then fetch_tarball pkgs name spec
67 else if spec.type == "git" then fetch_git spec
68 else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
69 else if spec.type == "builtin-url" then fetch_builtin-url name
70 else
71 abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
72
73 # Ports of functions for older nix versions
74
75 # a Nix version of mapAttrs if the built-in doesn't exist
76 mapAttrs = builtins.mapAttrs or (
77 f: set: with builtins;
78 listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
79 );
80
81 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
82 range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
83
84 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
85 stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
86
87 # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
88 stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
89 concatStrings = builtins.concatStringsSep "";
90
91 # fetchTarball version that is compatible between all the versions of Nix
92 builtins_fetchTarball = { url, name, sha256 }@attrs:
93 let
94 inherit (builtins) lessThan nixVersion fetchTarball;
95 in
96 if lessThan nixVersion "1.12" then
97 fetchTarball { inherit name url; }
98 else
99 fetchTarball attrs;
100
101 # fetchurl version that is compatible between all the versions of Nix
102 builtins_fetchurl = { url, sha256 }@attrs:
103 let
104 inherit (builtins) lessThan nixVersion fetchurl;
105 in
106 if lessThan nixVersion "1.12" then
107 fetchurl { inherit url; }
108 else
109 fetchurl attrs;
110
111 # Create the final "sources" from the config
112 mkSources = config:
113 mapAttrs (
114 name: spec:
115 if builtins.hasAttr "outPath" spec
116 then abort
117 "The values in sources.json should not have an 'outPath' attribute"
118 else
119 spec // { outPath = fetch config.pkgs name spec; }
120 ) config.sources;
121
122 # The "config" used by the fetchers
123 mkConfig =
124 { sourcesFile ? ./sources.json
125 , sources ? builtins.fromJSON (builtins.readFile sourcesFile)
126 , pkgs ? mkPkgs sources
127 }: rec {
128 # The sources, i.e. the attribute set of spec name to spec
129 inherit sources;
130
131 # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
132 inherit pkgs;
133 };
134in
135mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 3e77992e..a6630feb 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -4,42 +4,43 @@ let
4 mylibs = import ../lib { inherit pkgs; }; 4 mylibs = import ../lib { inherit pkgs; };
5in 5in
6rec { 6rec {
7 sources = import ../nix/sources.nix;
7 myEnvironments = callPackage ../environments {}; 8 myEnvironments = callPackage ../environments {};
8 boinctui = callPackage ../pkgs/boinctui {}; 9 boinctui = callPackage ./boinctui {};
9 cnagios = callPackage ../pkgs/cnagios { inherit mylibs; }; 10 cnagios = callPackage ./cnagios { inherit mylibs; };
10 duply = callPackage ../pkgs/duply {}; 11 duply = callPackage ./duply {};
11 flrn = callPackage ../pkgs/flrn { inherit mylibs; slang = callPackage ../pkgs/slang_1 {}; }; 12 flrn = callPackage ./flrn { inherit mylibs; slang = callPackage ./slang_1 {}; };
12 genius = callPackage ../pkgs/genius {}; 13 genius = callPackage ./genius {};
13 mtop = callPackage ../pkgs/mtop {}; 14 mtop = callPackage ./mtop {};
14 muttprint = callPackage ../pkgs/muttprint {}; 15 muttprint = callPackage ./muttprint {};
15 mutt-ics = callPackage ../pkgs/mutt-ics { inherit mylibs; }; 16 mutt-ics = callPackage ./mutt-ics { inherit mylibs; };
16 nagios-cli = callPackage ../pkgs/nagios-cli { inherit mylibs; }; 17 nagios-cli = callPackage ./nagios-cli { inherit mylibs; };
17 nagnu = callPackage ../pkgs/nagnu { inherit mylibs; }; 18 nagnu = callPackage ./nagnu { inherit mylibs; };
18 note = callPackage ../pkgs/note {}; 19 note = callPackage ./note {};
19 notmuch-python2 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python2Packages; }; 20 notmuch-python2 = callPackage ./notmuch/notmuch-python { pythonPackages = python2Packages; };
20 notmuch-python3 = callPackage ../pkgs/notmuch/notmuch-python { pythonPackages = python3Packages; }; 21 notmuch-python3 = callPackage ./notmuch/notmuch-python { pythonPackages = python3Packages; };
21 notmuch-vim = callPackage ../pkgs/notmuch/notmuch-vim {}; 22 notmuch-vim = callPackage ./notmuch/notmuch-vim {};
22 openarc = callPackage ../pkgs/openarc { inherit mylibs; }; 23 openarc = callPackage ./openarc { inherit mylibs; };
23 opendmarc = callPackage ../pkgs/opendmarc { libspf2 = callPackage ../pkgs/opendmarc/libspf2.nix {}; }; 24 opendmarc = callPackage ./opendmarc { libspf2 = callPackage ./opendmarc/libspf2.nix {}; };
24 pg_activity = callPackage ../pkgs/pg_activity { inherit mylibs; }; 25 pg_activity = callPackage ./pg_activity { inherit mylibs; };
25 pgloader = callPackage ../pkgs/pgloader {}; 26 pgloader = callPackage ./pgloader {};
26 predixy = callPackage ../pkgs/predixy { inherit mylibs; }; 27 predixy = callPackage ./predixy { inherit mylibs; };
27 rrsync_sudo = callPackage ../pkgs/rrsync_sudo {}; 28 rrsync_sudo = callPackage ./rrsync_sudo {};
28 telegram-cli = callPackage ../pkgs/telegram-cli { inherit mylibs; }; 29 telegram-cli = callPackage ./telegram-cli { inherit mylibs; };
29 telegram-history-dump = callPackage ../pkgs/telegram-history-dump { inherit mylibs; }; 30 telegram-history-dump = callPackage ./telegram-history-dump { inherit mylibs; };
30 telegramircd = callPackage ../pkgs/telegramircd { inherit mylibs; telethon = callPackage ../pkgs/telethon_sync {}; }; 31 telegramircd = callPackage ./telegramircd { inherit mylibs; telethon = callPackage ./telethon_sync {}; };
31 terminal-velocity = callPackage ../pkgs/terminal-velocity {}; 32 terminal-velocity = callPackage ./terminal-velocity {};
32 tiv = callPackage ../pkgs/tiv {}; 33 tiv = callPackage ./tiv {};
33 unicodeDoc = callPackage ../pkgs/unicode {}; 34 unicodeDoc = callPackage ./unicode {};
34 35
35 cardano = callPackage ../pkgs/crypto/cardano { inherit mylibs; }; 36 cardano = callPackage ./crypto/cardano { inherit mylibs; };
36 cardano-cli = callPackage ../pkgs/crypto/cardano-cli {}; 37 cardano-cli = callPackage ./crypto/cardano-cli {};
37 iota-cli-app = callPackage ../pkgs/crypto/iota-cli-app { inherit mylibs; }; 38 iota-cli-app = callPackage ./crypto/iota-cli-app { inherit mylibs; };
38 sia = callPackage ../pkgs/crypto/sia {}; 39 sia = callPackage ./crypto/sia {};
39 40
40 pure-ftpd = callPackage ../pkgs/pure-ftpd {}; 41 pure-ftpd = callPackage ./pure-ftpd {};
41 mpd = (callPackage ../pkgs/mpd_0_21 {}).mpd; 42 mpd = (callPackage ./mpd_0_21 {}).mpd;
42 mpd-small = (callPackage ../pkgs/mpd_0_21 {}).mpd-small; 43 mpd-small = (callPackage ./mpd_0_21 {}).mpd-small;
43 44
44 bitlbee-mastodon = callPackage ./bitlbee-mastodon {}; 45 bitlbee-mastodon = callPackage ./bitlbee-mastodon {};
45 46
@@ -73,4 +74,5 @@ rec {
73 sha256 = "0dh8qc3lzrba5mxxxh57i1374wc7ha3c30h7wsmj5zr7bhc5zm4p"; 74 sha256 = "0dh8qc3lzrba5mxxxh57i1374wc7ha3c30h7wsmj5zr7bhc5zm4p";
74 }) {}).monero; 75 }) {}).monero;
75 76
77 niv = (import sources.niv {}).niv;
76} 78}