wrapperPackages/dotfiles-wrapped: update inputs and format code

This commit is contained in:
Gabriel Arazas 2025-02-08 10:17:39 +08:00
parent c697504a53
commit f24dd8b6d5
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 34 additions and 44 deletions

View File

@ -3,33 +3,22 @@ let
data = builtins.fromJSON (builtins.readFile ./sources.json); data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version; version = data.version;
mkSource = mkSource = spec:
spec:
assert spec ? type; assert spec ? type;
let let
path = path = if spec.type == "Git" then
if spec.type == "Git" then mkGitSource spec
mkGitSource spec else if spec.type == "GitRelease" then
else if spec.type == "GitRelease" then mkGitSource spec
mkGitSource spec else if spec.type == "PyPi" then
else if spec.type == "PyPi" then mkPyPiSource spec
mkPyPiSource spec else if spec.type == "Channel" then
else if spec.type == "Channel" then mkChannelSource spec
mkChannelSource spec else
else builtins.throw "Unknown source type ${spec.type}";
builtins.throw "Unknown source type ${spec.type}"; in spec // { outPath = path; };
in
spec // { outPath = path; };
mkGitSource = mkGitSource = { repository, revision, url ? null, hash, branch ? null, ... }:
{
repository,
revision,
url ? null,
hash,
branch ? null,
...
}:
assert repository ? type; assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository # 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 # In the latter case, there we will always be an url to the tarball
@ -41,40 +30,41 @@ let
else else
assert repository.type == "Git"; assert repository.type == "Git";
let let
urlToName = urlToName = url: rev:
url: rev:
let let
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
short = builtins.substring 0 7 rev; short = builtins.substring 0 7 rev;
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; appendShort = if (builtins.match "[a-f0-9]*" rev) != null then
in "-${short}"
"${if matched == null then "source" else builtins.head matched}${appendShort}"; else
"";
in "${
if matched == null then "source" else builtins.head matched
}${appendShort}";
name = urlToName repository.url revision; name = urlToName repository.url revision;
in in builtins.fetchGit {
builtins.fetchGit {
url = repository.url; url = repository.url;
rev = revision; rev = revision;
inherit name; inherit name;
# hash = hash; # hash = hash;
}; };
mkPyPiSource = mkPyPiSource = { url, hash, ... }:
{ url, hash, ... }:
builtins.fetchurl { builtins.fetchurl {
inherit url; inherit url;
sha256 = hash; sha256 = hash;
}; };
mkChannelSource = mkChannelSource = { url, hash, ... }:
{ url, hash, ... }:
builtins.fetchTarball { builtins.fetchTarball {
inherit url; inherit url;
sha256 = hash; sha256 = hash;
}; };
in in if version == 3 then
if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins builtins.mapAttrs (_: mkSource) data.pins
else else
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" throw "Unsupported format version ${
toString version
} in sources.json. Try running `npins upgrade`"

View File

@ -8,9 +8,9 @@
"repo": "doomemacs" "repo": "doomemacs"
}, },
"branch": "master", "branch": "master",
"revision": "8b9168de6e6a9cabf13d1c92558e2ef71aa37a72", "revision": "2bc052425ca45a41532be0648ebd976d1bd2e6c1",
"url": "https://github.com/doomemacs/doomemacs/archive/8b9168de6e6a9cabf13d1c92558e2ef71aa37a72.tar.gz", "url": "https://github.com/doomemacs/doomemacs/archive/2bc052425ca45a41532be0648ebd976d1bd2e6c1.tar.gz",
"hash": "1b3dwzvxa3svi5bmzwbx847b0g9fggfdjbjacp7vy936x6ld51bc" "hash": "0a1px0igzhzl7mjl0wkp9jnb3sjggpbi2rnj0w2kga08d8frahcb"
}, },
"dotfiles": { "dotfiles": {
"type": "Git", "type": "Git",
@ -20,9 +20,9 @@
"repo": "dotfiles" "repo": "dotfiles"
}, },
"branch": "master", "branch": "master",
"revision": "0766497a925b0e87efa7b319e823aeaa77f2e1dd", "revision": "f2f7a9e221635e7e857b96ced7d651fc8e059a66",
"url": "https://github.com/foo-dogsquared/dotfiles/archive/0766497a925b0e87efa7b319e823aeaa77f2e1dd.tar.gz", "url": "https://github.com/foo-dogsquared/dotfiles/archive/f2f7a9e221635e7e857b96ced7d651fc8e059a66.tar.gz",
"hash": "0435h4cgz9wgyp9j6vygcbxp3i66vn29ab2jqpcpfgligipjnhhm" "hash": "181z505yqsscjngk78dpzfgw47a4ravr5xpfqyal9b38b2kvc6i9"
}, },
"nixgl": { "nixgl": {
"type": "Git", "type": "Git",