nixosConfigurations: move input forwarding to inline module
Inspired by https://jade.fyi/blog/flakes-arent-real/, this is better for composability: > it also doesn't work outside of the flake that's actually invoking nixpkgs.lib.nixosSystem. The latter is the much more sinister part, and the reason I would strongly recommend inline modules with closures instead of specialArgs: they break flake composition. For now, the `system` remains a specialArg, until I decide what to do with that.
This commit is contained in:
parent
4a43774913
commit
9ad1049f4a
|
@ -1,6 +1,7 @@
|
|||
{ config, pkgs, lib, inputs, ... }:
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
inputs = config.inputInjection.flake-inputs;
|
||||
unstable = inputs.nixos-unstable;
|
||||
|
||||
in
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -31,13 +31,24 @@
|
|||
# FIXME: allow different systems
|
||||
systems = flake-utils.lib.system;
|
||||
# necessary to make the top-level inputs available to system configuration
|
||||
# inspired by https://jade.fyi/blog/flakes-arent-real/
|
||||
inputInjection = {pkgs, lib, ...}: {
|
||||
options.inputInjection = lib.mkOption {
|
||||
type = with lib.types; attrsOf unspecified;
|
||||
default = {};
|
||||
};
|
||||
config.inputInjection = {
|
||||
flake-inputs = inputs;
|
||||
};
|
||||
};
|
||||
defaultModules = system: [
|
||||
{ _module.args = { inherit inputs system; }; }
|
||||
inputInjection
|
||||
];
|
||||
mkSystem = system: extraModules:
|
||||
nixpkgs.lib.nixosSystem rec {
|
||||
modules = (defaultModules system) ++ extraModules;
|
||||
inherit system;
|
||||
specialArgs = {inherit system;};
|
||||
};
|
||||
mkHomeManager = confName: user: system: # unfortunately, home-manager configs are still system-specific
|
||||
# FIXME: this is thus still linux-x86_64 specific
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ config, lib, pkgs, inputs, system, ...}:
|
||||
{ config, lib, pkgs, system, ...}:
|
||||
let
|
||||
unstable = inputs.nixos-unstable.legacyPackages.${system};
|
||||
unstable = config.inputInjection.flake-inputs.nixos-unstable.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, inputs, ...}:
|
||||
{ config, lib, pkgs, ...}:
|
||||
{
|
||||
imports = [
|
||||
../../common
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, modulesPath, inputs, ... }:
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, inputs, ...}:
|
||||
{ config, lib, pkgs, ...}:
|
||||
{
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, inputs, ...}:
|
||||
{ config, lib, pkgs, ...}:
|
||||
let
|
||||
fsOptions = [ "noatime" "ssd" "space_cache" "compress=zstd" ];
|
||||
in
|
||||
|
|
Loading…
Reference in a new issue