diff --git a/.github/workflows/update_deps.yaml b/.github/workflows/update_deps.yaml index 3e3f735..6777ddd 100644 --- a/.github/workflows/update_deps.yaml +++ b/.github/workflows/update_deps.yaml @@ -29,7 +29,7 @@ jobs: git reset --soft HEAD^ fi - if NPINS=$(nix run nixpkgs#npins -- -d ./pkgs update -f | grep -E '[^\(no changes\)]*url.*'); then + if NPINS=$(nix run nixpkgs#npins -- -d ./pkgs/npins update -f | grep -E '[^\(no changes\)]*url.*'); then MESSAGE="$MESSAGE npins url updates: diff --git a/module.nix b/module.nix index 6fc1bd7..eaa6b9a 100644 --- a/module.nix +++ b/module.nix @@ -13,6 +13,7 @@ let spicePkgs = self.legacyPackages.${pkgs.stdenv.hostPlatform.system}; extensionType = lib.types.either lib.types.pathInStore ( lib.types.submodule { + freeformType = lib.types.attrs; options = { src = lib.mkOption { type = lib.types.pathInStore; @@ -48,6 +49,7 @@ in inherit (spicePkgs.themes) default; type = lib.types.submodule { + freeformType = lib.types.attrs; options = { name = lib.mkOption { type = lib.types.str; @@ -171,6 +173,7 @@ in enabledCustomApps = lib.mkOption { type = lib.types.listOf ( lib.types.submodule { + freeformType = lib.types.attrs; options = { src = lib.mkOption { type = lib.types.pathInStore; diff --git a/pkgs/default.nix b/pkgs/default.nix index e5f661c..a1e7bf0 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,7 +4,7 @@ let spicePkgs = self.legacyPackages.${pkgs.stdenv.system}; in { - sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/pkgs/sources.json").pins; + sources = pkgs.callPackages "${self}/pkgs/npins/sources.nix" { }; spicetify = pkgs.callPackage "${self}/pkgs/spicetify.nix" { }; /* diff --git a/pkgs/sources.json b/pkgs/npins/sources.json similarity index 100% rename from pkgs/sources.json rename to pkgs/npins/sources.json diff --git a/pkgs/npins/sources.nix b/pkgs/npins/sources.nix new file mode 100644 index 0000000..2385c6c --- /dev/null +++ b/pkgs/npins/sources.nix @@ -0,0 +1,72 @@ +# Based off of: +# https://github.com/NixOS/nixpkgs/blob/776c3bee4769c616479393aeefceefeda16b6fcb/pkgs/tools/nix/npins/source.nix +{ + lib, + fetchurl, + fetchgit, + fetchzip, +}: +builtins.mapAttrs ( + _: + let + getZip = + { url, hash, ... }: + fetchzip { + inherit url; + sha256 = hash; + extension = "tar"; + + }; + mkGitSource = + { + repository, + revision, + url ? null, + hash, + ... + }@attrs: + assert repository ? type; + if url != null then + getZip attrs + else + assert repository.type == "Git"; + let + urlToName = + url: rev: + let + matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; + short = builtins.substring 0 7 rev; + appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; + in + "${if matched == null then "source" else builtins.head matched}${appendShort}"; + name = urlToName repository.url revision; + in + fetchgit { + inherit name; + inherit (repository) url; + rev = revision; + sha256 = hash; + }; + + mkPyPiSource = + { url, hash, ... }: + fetchurl { + inherit url; + sha256 = hash; + }; + in + spec: + assert spec ? type; + let + func = + { + Git = mkGitSource; + GitRelease = mkGitSource; + PyPi = mkPyPiSource; + Channel = getZip; + } + .${spec.type} or (builtins.throw "Unknown source type ${spec.type}"); + in + spec // { outPath = func spec; } + +) (lib.importJSON ./sources.json).pins