Skip to content

Commit

Permalink
use "source" for source names
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fricklerhandwerk committed Oct 17, 2023
1 parent 723f0ee commit e680cd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
24 changes: 4 additions & 20 deletions nix/sources.nix
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Niv/Sources.hs
Expand Up @@ -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
Expand Down Expand Up @@ -214,6 +216,7 @@ sourcesVersionToText = \case
V26 -> "26"
V27 -> "27"
V28 -> "28"
V29 -> "29"

latestVersionMD5 :: T.Text
latestVersionMD5 = sourcesVersionToMD5 maxBound
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e680cd8

Please sign in to comment.