From e680cd8b0100e1d6e56dbe809be9cbd23b3db921 Mon Sep 17 00:00:00 2001 From: fricklerhandwerk Date: Tue, 17 Oct 2023 13:11:16 +0200 Subject: [PATCH] use "source" for source names this removes a difference to how Nix currently fetches flake references. using a constant is preferrable because renaming the source won't force downstream rebuilds. there probably is no correct solution here, as any choice for the symbolic name is essentially arbitrary, and arguably symbolic names were an unfortunate design decision anyway. --- nix/sources.nix | 24 ++++-------------------- src/Niv/Sources.hs | 4 ++++ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/nix/sources.nix b/nix/sources.nix index fe3dadf..0e2494d 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -7,22 +7,16 @@ let # fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } + builtins_fetchurl { inherit (spec) url sha256; name = "source"; } else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + pkgs.fetchurl { inherit (spec) url sha256; name = "source"; }; fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + builtins_fetchTarball { name = "source"; inherit (spec) url sha256; } else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + pkgs.fetchzip { name = "source"; inherit (spec) url sha256; }; fetch_git = name: spec: let @@ -69,16 +63,6 @@ let # Various helpers # - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - # The set of packages used when specs are fetched using non-builtins. mkPkgs = sources: system: let diff --git a/src/Niv/Sources.hs b/src/Niv/Sources.hs index 751c455..979de1d 100644 --- a/src/Niv/Sources.hs +++ b/src/Niv/Sources.hs @@ -181,6 +181,8 @@ data SourcesNixVersion | -- formatting fix -- Apply statix suggestions V28 + | -- always use "source" for store path names + V29 deriving stock (Bounded, Enum, Eq) -- | A user friendly version @@ -214,6 +216,7 @@ sourcesVersionToText = \case V26 -> "26" V27 -> "27" V28 -> "28" + V29 -> "29" latestVersionMD5 :: T.Text latestVersionMD5 = sourcesVersionToMD5 maxBound @@ -254,6 +257,7 @@ sourcesVersionToMD5 = \case V26 -> "937bff93370a064c9000f13cec5867f9" V27 -> "8031ba9d8fbbc7401c800d0b84278ec8" V28 -> "26ed55356db7673935329210a4f8c4a5" + V29 -> "77f9fbf2fe7c64e079862e53145a2af9" -- | The MD5 sum of ./nix/sources.nix sourcesNixMD5 :: IO T.Text