summaryrefslogtreecommitdiff
path: root/npins/default.nix
diff options
context:
space:
mode:
authorstuebinm2024-04-28 21:30:47 +0200
committerstuebinm2024-04-29 00:02:55 +0200
commit9e7a775e2578e126dddb1c6f7514874265e3d08e (patch)
tree68a72299d6c5ca706ee357fdbc73d8dd4ceef010 /npins/default.nix
parent806593f53dde83f367fd9f6ee74a21aef97faf44 (diff)
yeet the nix flakes
this is, in the widest possible sense, a revert of e88fed18f499a3e8ac98c772bbb62f00d1f8d1d7, which was now a little over two years ago. Of course, lots of things have changed since then: - this uses npins instead of niv, which is both simpler and still maintained - i haven't brought back the old deploy lib; I still use deploy-rs (with some modifications) to deploy things - if you actually use my stuff downstream, you can now use packages/ & tests/ & modules/ as entry points directly, while still having some control over inputs - (since i also don't believe any downstream users actually exist, i've not bothered to have a shim flake.nix so your stuff probably just broke. well, it was an experimental feature, anyways) - in general there's a lot more of the old-fashioned structure back again, with default.nix files in subdirectories that form a structure, not like how almost everything was just imported in the one big flake.nix file For people who are interested in also having a non-flake config similar to this one, it's probably best to take a look at inputs.nix (and also at npins, of course)
Diffstat (limited to '')
-rw-r--r--npins/default.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/npins/default.nix b/npins/default.nix
new file mode 100644
index 0000000..891db57
--- /dev/null
+++ b/npins/default.nix
@@ -0,0 +1,64 @@
+# Generated by npins. Do not modify; will be overwritten regularly
+let
+ requireFile = { sha256, hashMode ? "recursive" }:
+ builtins.derivation {
+ name = "source";
+ outputHashMode = hashMode;
+ outputHashAlgo = "sha256";
+ outputHash = sha256;
+ preferLocalBuild = true;
+ allowSubstitutes = false;
+ builder = "builtins:fetchurl";
+ system = "builtin"; # builtins.currentSystem;
+ };
+
+ data = builtins.fromJSON (builtins.readFile ./sources.json);
+ version = data.version;
+
+ mkSource = spec:
+ assert spec ? type; let
+ path =
+ if spec.type == "Git" then mkGitSource spec
+ else if spec.type == "GitRelease" then mkGitSource spec
+ else if spec.type == "PyPi" then mkPyPiSource spec
+ else if spec.type == "Channel" then mkChannelSource spec
+ else builtins.throw "Unknown source type ${spec.type}";
+ in
+ spec // { outPath = path; };
+
+ mkGitSource = { repository, revision, url ? null, hash, ... }:
+ assert repository ? type;
+ # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
+ # In the latter case, there we will always be an url to the tarball
+ if url != null then
+ (builtins.fetchTarball {
+ inherit url;
+ sha256 = hash; # FIXME: check nix version & use SRI hashes
+ })
+ else assert repository.type == "Git";
+ let
+ cached = requireFile { sha256 = hash; };
+ fetched = builtins.fetchGit {
+ url = repository.url;
+ rev = revision;
+ };
+ in if builtins.pathExists (builtins.unsafeDiscardStringContext cached.outPath)
+ then cached.outPath
+ else builtins.trace "npins: re-fetching source ${repository.url}" fetched.outPath;
+
+ mkPyPiSource = { url, hash, ... }:
+ builtins.fetchurl {
+ inherit url;
+ sha256 = hash;
+ };
+
+ mkChannelSource = { url, hash, ... }:
+ builtins.fetchTarball {
+ inherit url;
+ sha256 = hash;
+ };
+in
+if version == 3 then
+ builtins.mapAttrs (_: mkSource) data.pins
+else
+ throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"