nixos/iso-image.nix: nixfmt

This commit is contained in:
Will Fancher
2025-01-20 19:11:22 -05:00
parent 6607cf789e
commit da9a092c34
3 changed files with 550 additions and 461 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,30 @@
# This module generates nixos-install, nixos-rebuild, # This module generates nixos-install, nixos-rebuild,
# nixos-generate-config, etc. # nixos-generate-config, etc.
{ config, lib, pkgs, options, ... }: {
config,
lib,
pkgs,
options,
...
}:
let let
makeProg = args: pkgs.replaceVarsWith (args // { makeProg =
dir = "bin"; args:
isExecutable = true; pkgs.replaceVarsWith (
nativeBuildInputs = [ args
pkgs.installShellFiles // {
]; dir = "bin";
postInstall = '' isExecutable = true;
installManPage ${args.manPage} nativeBuildInputs = [
''; pkgs.installShellFiles
}); ];
postInstall = ''
installManPage ${args.manPage}
'';
}
);
nixos-generate-config = makeProg { nixos-generate-config = makeProg {
name = "nixos-generate-config"; name = "nixos-generate-config";
@@ -36,13 +47,17 @@ let
inherit (pkgs) runtimeShell; inherit (pkgs) runtimeShell;
inherit (config.system.nixos) version codeName revision; inherit (config.system.nixos) version codeName revision;
inherit (config.system) configurationRevision; inherit (config.system) configurationRevision;
json = builtins.toJSON ({ json = builtins.toJSON (
nixosVersion = config.system.nixos.version; {
} // lib.optionalAttrs (config.system.nixos.revision != null) { nixosVersion = config.system.nixos.version;
nixpkgsRevision = config.system.nixos.revision; }
} // lib.optionalAttrs (config.system.configurationRevision != null) { // lib.optionalAttrs (config.system.nixos.revision != null) {
configurationRevision = config.system.configurationRevision; nixpkgsRevision = config.system.nixos.revision;
}); }
// lib.optionalAttrs (config.system.configurationRevision != null) {
configurationRevision = config.system.configurationRevision;
}
);
}; };
manPage = ./manpages/nixos-version.8; manPage = ./manpages/nixos-version.8;
}; };
@@ -266,26 +281,46 @@ in
''; '';
}; };
imports = let imports =
mkToolModule = { name, package ? pkgs.${name} }: { config, ... }: { let
options.system.tools.${name}.enable = lib.mkEnableOption "${name} script" // { mkToolModule =
default = config.nix.enable && ! config.system.disableInstallerTools; {
defaultText = "config.nix.enable && !config.system.disableInstallerTools"; name,
}; package ? pkgs.${name},
}:
{ config, ... }:
{
options.system.tools.${name}.enable = lib.mkEnableOption "${name} script" // {
default = config.nix.enable && !config.system.disableInstallerTools;
defaultText = "config.nix.enable && !config.system.disableInstallerTools";
};
config = lib.mkIf config.system.tools.${name}.enable { config = lib.mkIf config.system.tools.${name}.enable {
environment.systemPackages = [ package ]; environment.systemPackages = [ package ];
}; };
}; };
in [ in
(mkToolModule { name = "nixos-build-vms"; }) [
(mkToolModule { name = "nixos-enter"; }) (mkToolModule { name = "nixos-build-vms"; })
(mkToolModule { name = "nixos-generate-config"; package = config.system.build.nixos-generate-config; }) (mkToolModule { name = "nixos-enter"; })
(mkToolModule { name = "nixos-install"; package = config.system.build.nixos-install; }) (mkToolModule {
(mkToolModule { name = "nixos-option"; }) name = "nixos-generate-config";
(mkToolModule { name = "nixos-rebuild"; package = config.system.build.nixos-rebuild; }) package = config.system.build.nixos-generate-config;
(mkToolModule { name = "nixos-version"; package = nixos-version; }) })
]; (mkToolModule {
name = "nixos-install";
package = config.system.build.nixos-install;
})
(mkToolModule { name = "nixos-option"; })
(mkToolModule {
name = "nixos-rebuild";
package = config.system.build.nixos-rebuild;
})
(mkToolModule {
name = "nixos-version";
package = nixos-version;
})
];
config = { config = {
documentation.man.man-db.skipPackages = [ nixos-version ]; documentation.man.man-db.skipPackages = [ nixos-version ];
@@ -293,10 +328,7 @@ in
# These may be used in auxiliary scripts (ie not part of toplevel), so they are defined unconditionally. # These may be used in auxiliary scripts (ie not part of toplevel), so they are defined unconditionally.
system.build = { system.build = {
inherit nixos-generate-config nixos-install; inherit nixos-generate-config nixos-install;
nixos-rebuild = nixos-rebuild = if config.system.rebuild.enableNg then nixos-rebuild-ng else nixos-rebuild;
if config.system.rebuild.enableNg
then nixos-rebuild-ng
else nixos-rebuild;
nixos-option = lib.warn "Accessing nixos-option through `config.system.build` is deprecated, use `pkgs.nixos-option` instead." pkgs.nixos-option; nixos-option = lib.warn "Accessing nixos-option through `config.system.build` is deprecated, use `pkgs.nixos-option` instead." pkgs.nixos-option;
nixos-enter = lib.warn "Accessing nixos-enter through `config.system.build` is deprecated, use `pkgs.nixos-enter` instead." pkgs.nixos-enter; nixos-enter = lib.warn "Accessing nixos-enter through `config.system.build` is deprecated, use `pkgs.nixos-enter` instead." pkgs.nixos-enter;
}; };

View File

@@ -1,7 +1,12 @@
# This module defines the software packages included in the "minimal" # This module defines the software packages included in the "minimal"
# installation CD. It might be useful elsewhere. # installation CD. It might be useful elsewhere.
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ {
# Include some utilities that are useful for installing or repairing # Include some utilities that are useful for installing or repairing
@@ -43,9 +48,14 @@
]; ];
# Include support for various filesystems and tools to create / manipulate them. # Include support for various filesystems and tools to create / manipulate them.
boot.supportedFilesystems = boot.supportedFilesystems = [
[ "btrfs" "cifs" "f2fs" "ntfs" "vfat" "xfs" ] ++ "btrfs"
lib.optional (lib.meta.availableOn pkgs.stdenv.hostPlatform config.boot.zfs.package) "zfs"; "cifs"
"f2fs"
"ntfs"
"vfat"
"xfs"
] ++ lib.optional (lib.meta.availableOn pkgs.stdenv.hostPlatform config.boot.zfs.package) "zfs";
# Configure host id for ZFS to work # Configure host id for ZFS to work
networking.hostId = lib.mkDefault "8425e349"; networking.hostId = lib.mkDefault "8425e349";