1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-24 00:21:47 +03:00

core: pin registry by ref

Users may wish to change the default value of override and nixos
inputs. If they do so, we want the registry listing to reflect the
proper ref names afterwards.

Also create a shell alias to easily search every flake in nix.registry.
This commit is contained in:
Timothy DeHerrera 2021-02-14 15:50:49 -07:00
parent bf34d2071f
commit 3a735ce70b
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122
2 changed files with 65 additions and 23 deletions

View File

@ -1,11 +1,12 @@
{ lib
{ extern
, home
, lib
, nixos
, override
, nixos-hardware
, override
, pkgs
, self
, system
, extern
, ...
}:
let
@ -36,29 +37,57 @@ let
modules;
};
global = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
global =
let
inherit (lock) nodes;
hardware.enableRedistributableFirmware = lib.mkDefault true;
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
in
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
networking.hostName = hostName;
nix.nixPath = [
"nixos-unstable=${override}"
"nixos=${nixos}"
"nixpkgs=${nixos}"
];
hardware.enableRedistributableFirmware = lib.mkDefault true;
nixpkgs = { inherit pkgs; };
networking.hostName = hostName;
nix.registry = {
nixflk.flake = self;
nixpkgs.flake = nixos;
nix.nixPath = [
"nixpkgs=${nixos}"
"nixos-config=${self}/compat/nixos"
"home-manager=${home}"
];
nixpkgs = { inherit pkgs; };
nix.registry = {
flk.flake = self;
nixos = {
exact = true;
from = nodes.nixos.original;
to = {
inherit (nixos) lastModified narHash rev;
path = override.outPath;
type = "path";
};
};
override = {
exact = true;
from = nodes.override.original;
to = {
inherit (override) lastModified narHash rev;
path = override.outPath;
type = "path";
};
};
};
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
local = {
require = [
(import "${toString ./.}/${hostName}.nix")

View File

@ -65,8 +65,8 @@ in
nr = "np remove";
ns = "n search --no-update-lock-file";
nf = "n flake";
nepl = "n repl '<nixos>'";
srch = "ns nixpkgs";
nepl = "n repl '<nixpkgs>'";
srch = "nsni";
nrb = ifSudo "sudo nixos-rebuild";
mn = ''
manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
@ -93,7 +93,20 @@ in
dn = ifSudo "s systemctl stop";
jtl = "journalctl";
};
} // lib.mapAttrs'
(n: v:
let
prefix = lib.concatStrings (lib.take 2 (lib.stringToCharacters n));
ref = from:
if from ? ref
then "ns ${from.id}/${from.ref}"
else "ns ${from.id}";
in
lib.nameValuePair
"ns${prefix}"
(ref v.from)
)
config.nix.registry;
};