nix-daemon.nix: Add option nix.registry
This allows you to specify the system-wide flake registry. One use is to pin 'nixpkgs' to the Nixpkgs version used to build the system: nix.registry.nixpkgs.flake = nixpkgs; where 'nixpkgs' is a flake input. This ensures that commands like $ nix run nixpkgs#hello pull in a minimum of additional store paths. You can also use this to redirect flakes, e.g. nix.registry.nixpkgs.to = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; };
This commit is contained in:
parent
9737f24919
commit
74e7ef35fe
|
@ -25,8 +25,9 @@
|
||||||
import ./nixos/lib/eval-config.nix (args // {
|
import ./nixos/lib/eval-config.nix (args // {
|
||||||
modules = modules ++
|
modules = modules ++
|
||||||
[ { system.nixos.versionSuffix =
|
[ { system.nixos.versionSuffix =
|
||||||
".${lib.substring 0 8 self.lastModified}.${self.shortRev or "dirty"}";
|
".${lib.substring 0 8 (self.lastModifiedDate or self.lastModified)}.${self.shortRev or "dirty"}";
|
||||||
system.nixos.revision = lib.mkIf (self ? rev) self.rev;
|
system.nixos.revision = lib.mkIf (self ? rev) self.rev;
|
||||||
|
nix.registry.nixpkgs.flake = lib.mkDefault self;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
|
@ -376,6 +376,59 @@ in
|
||||||
If enabled (the default), checks that Nix can parse the generated nix.conf.
|
If enabled (the default), checks that Nix can parse the generated nix.conf.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
registry = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule (
|
||||||
|
let
|
||||||
|
inputAttrs = types.attrsOf (types.oneOf [types.str types.int types.bool types.package]);
|
||||||
|
in
|
||||||
|
{ config, name, ... }:
|
||||||
|
{ options = {
|
||||||
|
from = mkOption {
|
||||||
|
type = inputAttrs;
|
||||||
|
example = { type = "indirect"; id = "nixpkgs"; };
|
||||||
|
description = "The flake reference to be rewritten.";
|
||||||
|
};
|
||||||
|
to = mkOption {
|
||||||
|
type = inputAttrs;
|
||||||
|
example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; };
|
||||||
|
description = "The flake reference to which <option>from></option> is to be rewritten.";
|
||||||
|
};
|
||||||
|
flake = mkOption {
|
||||||
|
type = types.unspecified;
|
||||||
|
default = null;
|
||||||
|
example = literalExample "nixpkgs";
|
||||||
|
description = ''
|
||||||
|
The flake input to which <option>from></option> is to be rewritten.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
exact = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether the <option>from</option> reference needs to match exactly. If set,
|
||||||
|
a <option>from</option> reference like <literal>nixpkgs</literal> does not
|
||||||
|
match with a reference like <literal>nixpkgs/nixos-20.03</literal>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
from = mkDefault { type = "indirect"; id = name; };
|
||||||
|
to = mkIf (config.flake != null)
|
||||||
|
({ type = "path";
|
||||||
|
path = config.flake.outPath;
|
||||||
|
} // lib.filterAttrs
|
||||||
|
(n: v: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash")
|
||||||
|
config.flake);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
A system-wide flake registry.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -390,6 +443,11 @@ in
|
||||||
|
|
||||||
environment.etc."nix/nix.conf".source = nixConf;
|
environment.etc."nix/nix.conf".source = nixConf;
|
||||||
|
|
||||||
|
environment.etc."nix/registry.json".text = builtins.toJSON {
|
||||||
|
version = 2;
|
||||||
|
flakes = mapAttrsToList (n: v: { inherit (v) from to exact; }) cfg.registry;
|
||||||
|
};
|
||||||
|
|
||||||
# List of machines for distributed Nix builds in the format
|
# List of machines for distributed Nix builds in the format
|
||||||
# expected by build-remote.pl.
|
# expected by build-remote.pl.
|
||||||
environment.etc."nix/machines" =
|
environment.etc."nix/machines" =
|
||||||
|
|
|
@ -19,7 +19,7 @@ releaseTools.sourceTarball {
|
||||||
version = pkgs.lib.fileContents ../../.version;
|
version = pkgs.lib.fileContents ../../.version;
|
||||||
versionSuffix = "pre${
|
versionSuffix = "pre${
|
||||||
if nixpkgs ? lastModified
|
if nixpkgs ? lastModified
|
||||||
then builtins.substring 0 8 nixpkgs.lastModified
|
then builtins.substring 0 8 (nixpkgs.lastModifiedDate or nixpkgs.lastModified)
|
||||||
else toString nixpkgs.revCount}.${nixpkgs.shortRev or "dirty"}";
|
else toString nixpkgs.revCount}.${nixpkgs.shortRev or "dirty"}";
|
||||||
|
|
||||||
buildInputs = [ nix.out jq lib-tests pkgs.brotli ];
|
buildInputs = [ nix.out jq lib-tests pkgs.brotli ];
|
||||||
|
|
Loading…
Reference in New Issue