mirror of
https://github.com/nmattia/niv.git
synced 2024-09-19 11:27:40 +03:00
sources.nix: bootstrap with a custom system
When combining Nix Flakes with niv, `builtins.currentSystem` is disabled. This allows to bootstrap nixpkgs by passing the system from the flake evaluation.
This commit is contained in:
parent
d13bf5ff11
commit
de84001689
@ -59,10 +59,10 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
# The set of packages used when specs are fetched using non-builtins.
|
# The set of packages used when specs are fetched using non-builtins.
|
||||||
mkPkgs = sources:
|
mkPkgs = sources: system:
|
||||||
let
|
let
|
||||||
sourcesNixpkgs =
|
sourcesNixpkgs =
|
||||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||||
in
|
in
|
||||||
@ -157,7 +157,8 @@ let
|
|||||||
mkConfig =
|
mkConfig =
|
||||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||||
, pkgs ? mkPkgs sources
|
, system ? builtins.currentSystem
|
||||||
|
, pkgs ? mkPkgs sources system
|
||||||
}: rec {
|
}: rec {
|
||||||
# The sources, i.e. the attribute set of spec name to spec
|
# The sources, i.e. the attribute set of spec name to spec
|
||||||
inherit sources;
|
inherit sources;
|
||||||
|
@ -168,6 +168,8 @@ data SourcesNixVersion
|
|||||||
V21
|
V21
|
||||||
| -- Stop setting `ref` and use `branch` and `tag` in sources
|
| -- Stop setting `ref` and use `branch` and `tag` in sources
|
||||||
V22
|
V22
|
||||||
|
| -- Allow to pass custom system to bootstrap niv in pure mode
|
||||||
|
V23
|
||||||
deriving stock (Bounded, Enum, Eq)
|
deriving stock (Bounded, Enum, Eq)
|
||||||
|
|
||||||
-- | A user friendly version
|
-- | A user friendly version
|
||||||
@ -195,6 +197,7 @@ sourcesVersionToText = \case
|
|||||||
V20 -> "20"
|
V20 -> "20"
|
||||||
V21 -> "21"
|
V21 -> "21"
|
||||||
V22 -> "22"
|
V22 -> "22"
|
||||||
|
V23 -> "23"
|
||||||
|
|
||||||
latestVersionMD5 :: T.Text
|
latestVersionMD5 :: T.Text
|
||||||
latestVersionMD5 = sourcesVersionToMD5 maxBound
|
latestVersionMD5 = sourcesVersionToMD5 maxBound
|
||||||
@ -229,6 +232,7 @@ sourcesVersionToMD5 = \case
|
|||||||
V20 -> "ab4263aa63ccf44b4e1510149ce14eff"
|
V20 -> "ab4263aa63ccf44b4e1510149ce14eff"
|
||||||
V21 -> "c501eee378828f7f49828a140dbdbca3"
|
V21 -> "c501eee378828f7f49828a140dbdbca3"
|
||||||
V22 -> "935d1d2f0bf95fda977a6e3a7e548ed4"
|
V22 -> "935d1d2f0bf95fda977a6e3a7e548ed4"
|
||||||
|
V23 -> "4111204b613ec688e2669516dd313440"
|
||||||
|
|
||||||
-- | The MD5 sum of ./nix/sources.nix
|
-- | The MD5 sum of ./nix/sources.nix
|
||||||
sourcesNixMD5 :: IO T.Text
|
sourcesNixMD5 :: IO T.Text
|
||||||
|
Loading…
Reference in New Issue
Block a user