Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(srvos.flake): export the flake further #496

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions nixos/common/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@

let
cfg = config.srvos;

flake-registry = pkgs.writers.writeJSON "flake-registry.json" {
version = 2;
flakes = pkgs.lib.mapAttrsToList (name: value: {
exact = true;
from = {
id = name;
type = "indirect";
};
to = {
path = toString value;
type = "path";
};
}) ({ self = cfg.flake; } // cfg.flake.inputs);
};
in
{
options.srvos = {
Expand Down Expand Up @@ -42,6 +57,9 @@ in
};
};
config = lib.mkIf (cfg.flake != null) {
nix.settings.nix-path = lib.mkIf (cfg.flake.inputs ? nixpkgs) "nixpkgs=${cfg.flake.inputs.nixpkgs}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a bit wonky in nix versions < 2.24: NixOS/nix#9574 (comment)

nix.settings.flake-registry = lib.mkDefault flake-registry;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want this by default because this will upload nixpkgs to all kinds of machines, which can overhead and slow to upload. There is also a proper nixos option for this: https://github.com/Mic92/dotfiles/blob/9e2f4683cdf6a942e8ffc65ed3aa5ef27aaa4652/nixos/modules/pinned-registry.nix#L3

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just now the module was using builtins.unsafeDiscardStringContext

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also potentially Nixos has something like this now as well?


system.extraSystemBuilderCmds = lib.optionalString cfg.symlinkFlake ''
ln -s ${cfg.flake} $out/flake
'';
Expand Down