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 d38978d
Showing 1 changed file with 4 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

0 comments on commit d38978d

Please sign in to comment.