From f6754032eee331de351b45b08872a21c59c410f8 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 27 Jul 2021 20:56:48 -0500 Subject: [PATCH 1/2] nixos/installer: force root fs type installer media can be used on top of existing host configs. In such scenarions, root fs types will already be defined. Before this change, this will inevitably lead to the following error: ```console error: The option `fileSystems./.fsType' has conflicting definition values: - In `/nix/store/2nl5cl4mf6vnldpbxhrbzfh0n8rsv9fm-source/DevOS/os/hardware/common.nix': "ext4" - In `/nix/store/jbch90yqx6gg1h3fq30jjj2b6h6jfjgs-source/nixos/modules/installer/cd-dvd/iso-image.nix': "tmpfs" ``` With this patch, the installers will override those values according to their own local requirement. Use `mkOverride 60` so that conscientious overriding specially targeted at the installer, e.g. with `mkForce` is still straight forward. (cherry picked from commit c219fdffad3fa76c43824bee34d5fb424ff95b87) --- nixos/modules/installer/cd-dvd/iso-image.nix | 6 +++++- nixos/modules/installer/netboot/netboot.nix | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index c2836b5a9a1..ef618d102a7 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -644,7 +644,11 @@ in ]; fileSystems."/" = - { fsType = "tmpfs"; + # This module is often over-layed onto an existing host config + # that defines `/`. We use mkOverride 60 to override standard + # values, but at the same time leave room for mkForce values + # targeted at the image build. + { fsType = mkOverride 60 "tmpfs"; options = [ "mode=0755" ]; }; diff --git a/nixos/modules/installer/netboot/netboot.nix b/nixos/modules/installer/netboot/netboot.nix index fa074fdfcc6..d3a61436093 100644 --- a/nixos/modules/installer/netboot/netboot.nix +++ b/nixos/modules/installer/netboot/netboot.nix @@ -30,7 +30,11 @@ with lib; else [ pkgs.grub2 pkgs.syslinux ]); fileSystems."/" = - { fsType = "tmpfs"; + # This module is often over-layed onto an existing host config + # that defines `/`. We use mkOverride 60 to override standard + # values, but at the same time leave room for mkForce values + # targeted at the image build. + { fsType = mkOverride 60 "tmpfs"; options = [ "mode=0755" ]; }; From a791442a31afe47ba7e66dd61786edaee2f6727e Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 28 Jul 2021 07:54:00 -0500 Subject: [PATCH 2/2] nixos/nix-daemon: fix registry flake type Before this commit, the `flake` option was typed with `types.unspecified`. This type get's merged via [`mergeDefaultOption`](https://github.com/NixOS/nixpkgs/blob/ebb592a04c5282f316d60cd4aba066f6e5d74b65/lib/options.nix#L119-L128), which has a line ```nix else if all isFunction list then x: mergeDefaultOption loc (map (f: f x) list) ``` `lib.isFunction` detects an attrs in the shape of `{__functor = ...}` as a function and hence this line substitutes such attrs with a function (f: f x). If now, a flake input has a `__functor` as it's output, this will coerce the once attrs to a function. This breaks a lot of things later in the stack, for example a later `lib.filterAttrs seive ` will fail for obious reasons. According to @infinisil, `types.unspecified` is due to deprecation. In the meantime this PR provides a specific fix for the specific problem discovered. (cherry picked from commit ecae25c3ef137d972e909eb0e85960d90481789e) --- nixos/modules/services/misc/nix-daemon.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 133e96da0ec..70b27b7d3d0 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -458,7 +458,7 @@ in description = "The flake reference to which is to be rewritten."; }; flake = mkOption { - type = types.unspecified; + type = types.nullOr types.attrs; default = null; example = literalExample "nixpkgs"; description = ''