Unverified Commit ab6f1d83 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge master into staging-next

parents bea90dbe b94f2597
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2476,6 +2476,13 @@
    github = "beezow";
    githubId = 42082156;
  };
  ben9986 = {
    name = "Ben Carmichael";
    email = "ben9986.unvmn@passinbox.com";
    github = "ben9986";
    githubId = 38633150;
    keys = [ { fingerprint = "03C7 A587 74B3 F0E8 CE1F  4F8E ABBC DD77 69BC D3B0"; } ];
  };
  benaryorg = {
    name = "benaryorg";
    email = "binary@benary.org";
+3 −0
Original line number Diff line number Diff line
@@ -197,6 +197,9 @@
  moved into the top level scope (i.e., `budgie.budgie-desktop` is now
  `budgie-desktop`)

- The method to safely handle secrets in the `networking.wireless` module has been changed to benefit from a [new feature](https://w1.fi/cgit/hostap/commit/?id=e680a51e94a33591f61edb210926bcb71217a21a) of wpa_supplicant.
  The syntax to refer to secrets has changed slightly and the option `networking.wireless.environmentFile` has been replaced by `networking.wireless.secretsFile`; see the description of the latter for how to upgrade.

- All Cinnamon and XApp packages have been moved to top-level (i.e., `cinnamon.nemo` is now `nemo`).

- All GNOME packages have been moved to top-level (i.e., `gnome.nautilus` is now `nautilus`).
+48 −52
Original line number Diff line number Diff line
# This module creates a bootable ISO image containing the given NixOS
# configuration.  The derivation for the ISO image will be placed in
# config.system.build.isoImage.

{ config, lib, pkgs, ... }:

with lib;

let
  /**
   * Given a list of `options`, concats the result of mapping each options
@@ -22,8 +18,8 @@ let
      (option: ''
        menuentry '${defaults.name} ${
        # Name appended to menuentry defaults to params if no specific name given.
        option.name or (optionalString (option ? params) "(${option.params})")
        }' ${optionalString (option ? class) " --class ${option.class}"} {
        option.name or (lib.optionalString (option ? params) "(${option.params})")
        }' ${lib.optionalString (option ? class) " --class ${option.class}"} {
          # Fallback to UEFI console for boot, efifb sometimes has difficulties.
          terminal_output console

@@ -153,8 +149,8 @@ let
    APPEND ${toString config.boot.loader.grub.memtest86.params}
  '';

  isolinuxCfg = concatStringsSep "\n"
    ([ baseIsolinuxCfg ] ++ optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);
  isolinuxCfg = lib.concatStringsSep "\n"
    ([ baseIsolinuxCfg ] ++ lib.optional config.boot.loader.grub.memtest86.enable isolinuxMemtest86Entry);

  refindBinary = if targetArch == "x64" || targetArch == "aa64" then "refind_${targetArch}.efi" else null;

@@ -182,7 +178,7 @@ let
    insmod gfxterm
    insmod png
    set gfxpayload=keep
    set gfxmode=${concatStringsSep "," [
    set gfxmode=${lib.concatStringsSep "," [
      # GRUB will use the first valid mode listed here.
      # `auto` will sometimes choose the smallest valid mode it detects.
      # So instead we'll list a lot of possibly valid modes :/
@@ -321,7 +317,7 @@ let

    cat <<EOF > $out/EFI/boot/grub.cfg

    set textmode=${boolToString (config.isoImage.forceTextMode)}
    set textmode=${lib.boolToString (config.isoImage.forceTextMode)}
    set timeout=${toString grubEfiTimeout}

    clear
@@ -480,7 +476,7 @@ in
{
  options = {

    isoImage.isoName = mkOption {
    isoImage.isoName = lib.mkOption {
      default = "${config.isoImage.isoBaseName}.iso";
      type = lib.types.str;
      description = ''
@@ -488,7 +484,7 @@ in
      '';
    };

    isoImage.isoBaseName = mkOption {
    isoImage.isoBaseName = lib.mkOption {
      default = config.system.nixos.distroId;
      type = lib.types.str;
      description = ''
@@ -496,7 +492,7 @@ in
      '';
    };

    isoImage.compressImage = mkOption {
    isoImage.compressImage = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
@@ -505,7 +501,7 @@ in
      '';
    };

    isoImage.squashfsCompression = mkOption {
    isoImage.squashfsCompression = lib.mkOption {
      default = "zstd -Xcompression-level 19";
      type = lib.types.nullOr lib.types.str;
      description = ''
@@ -515,7 +511,7 @@ in
      example = "zstd -Xcompression-level 6";
    };

    isoImage.edition = mkOption {
    isoImage.edition = lib.mkOption {
      default = "";
      type = lib.types.str;
      description = ''
@@ -524,9 +520,9 @@ in
      '';
    };

    isoImage.volumeID = mkOption {
    isoImage.volumeID = lib.mkOption {
      # nixos-$EDITION-$RELEASE-$ARCH
      default = "nixos${optionalString (config.isoImage.edition != "") "-${config.isoImage.edition}"}-${config.system.nixos.release}-${pkgs.stdenv.hostPlatform.uname.processor}";
      default = "nixos${lib.optionalString (config.isoImage.edition != "") "-${config.isoImage.edition}"}-${config.system.nixos.release}-${pkgs.stdenv.hostPlatform.uname.processor}";
      type = lib.types.str;
      description = ''
        Specifies the label or volume ID of the generated ISO image.
@@ -535,8 +531,8 @@ in
      '';
    };

    isoImage.contents = mkOption {
      example = literalExpression ''
    isoImage.contents = lib.mkOption {
      example = lib.literalExpression ''
        [ { source = pkgs.memtest86 + "/memtest.bin";
            target = "boot/memtest.bin";
          }
@@ -548,15 +544,15 @@ in
      '';
    };

    isoImage.storeContents = mkOption {
      example = literalExpression "[ pkgs.stdenv ]";
    isoImage.storeContents = lib.mkOption {
      example = lib.literalExpression "[ pkgs.stdenv ]";
      description = ''
        This option lists additional derivations to be included in the
        Nix store in the generated ISO image.
      '';
    };

    isoImage.includeSystemBuildDependencies = mkOption {
    isoImage.includeSystemBuildDependencies = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
@@ -568,7 +564,7 @@ in
      '';
    };

    isoImage.makeBiosBootable = mkOption {
    isoImage.makeBiosBootable = lib.mkOption {
      # Before this option was introduced, images were BIOS-bootable if the
      # hostPlatform was x86-based. This option is enabled by default for
      # backwards compatibility.
@@ -586,7 +582,7 @@ in
      '';
    };

    isoImage.makeEfiBootable = mkOption {
    isoImage.makeEfiBootable = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
@@ -594,7 +590,7 @@ in
      '';
    };

    isoImage.makeUsbBootable = mkOption {
    isoImage.makeUsbBootable = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
@@ -602,7 +598,7 @@ in
      '';
    };

    isoImage.efiSplashImage = mkOption {
    isoImage.efiSplashImage = lib.mkOption {
      default = pkgs.fetchurl {
          url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/a9e05d7deb38a8e005a2b52575a3f59a63a4dba0/bootloader/efi-background.png";
          sha256 = "18lfwmp8yq923322nlb9gxrh5qikj1wsk6g5qvdh31c4h5b1538x";
@@ -612,7 +608,7 @@ in
      '';
    };

    isoImage.splashImage = mkOption {
    isoImage.splashImage = lib.mkOption {
      default = pkgs.fetchurl {
          url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/a9e05d7deb38a8e005a2b52575a3f59a63a4dba0/bootloader/isolinux/bios-boot.png";
          sha256 = "1wp822zrhbg4fgfbwkr7cbkr4labx477209agzc0hr6k62fr6rxd";
@@ -622,15 +618,15 @@ in
      '';
    };

    isoImage.grubTheme = mkOption {
    isoImage.grubTheme = lib.mkOption {
      default = pkgs.nixos-grub2-theme;
      type = types.nullOr (types.either types.path types.package);
      type = lib.types.nullOr (lib.types.either lib.types.path lib.types.package);
      description = ''
        The grub2 theme used for UEFI boot.
      '';
    };

    isoImage.syslinuxTheme = mkOption {
    isoImage.syslinuxTheme = lib.mkOption {
      default = ''
        MENU TITLE ${config.system.nixos.distroName}
        MENU RESOLUTION 800 600
@@ -655,15 +651,15 @@ in
        MENU COLOR UNSEL        37;44      #FF000000    #00000000   none
        MENU COLOR SEL          7;37;40    #FFFFFFFF    #FF5277C3   std
      '';
      type = types.str;
      type = lib.types.str;
      description = ''
        The syslinux theme used for BIOS boot.
      '';
    };

    isoImage.prependToMenuLabel = mkOption {
    isoImage.prependToMenuLabel = lib.mkOption {
      default = "";
      type = types.str;
      type = lib.types.str;
      example = "Install ";
      description = ''
        The string to prepend before the menu label for the NixOS system.
@@ -674,9 +670,9 @@ in
      '';
    };

    isoImage.appendToMenuLabel = mkOption {
    isoImage.appendToMenuLabel = lib.mkOption {
      default = " Installer";
      type = types.str;
      type = lib.types.str;
      example = " Live System";
      description = ''
        The string to append after the menu label for the NixOS system.
@@ -687,9 +683,9 @@ in
      '';
    };

    isoImage.forceTextMode = mkOption {
    isoImage.forceTextMode = lib.mkOption {
      default = false;
      type = types.bool;
      type = lib.types.bool;
      example = true;
      description = ''
        Whether to use text mode instead of graphical grub.
@@ -706,7 +702,7 @@ in
  # store them in lib so we can mkImageMediaOverride the
  # entire file system layout in installation media (only)
  config.lib.isoFileSystems = {
    "/" = mkImageMediaOverride
    "/" = lib.mkImageMediaOverride
      {
        fsType = "tmpfs";
        options = [ "mode=0755" ];
@@ -715,7 +711,7 @@ in
    # Note that /dev/root is a symlink to the actual root device
    # specified on the kernel command line, created in the stage 1
    # init script.
    "/iso" = mkImageMediaOverride
    "/iso" = lib.mkImageMediaOverride
      { device = "/dev/root";
        neededForBoot = true;
        noCheck = true;
@@ -723,20 +719,20 @@ in

    # In stage 1, mount a tmpfs on top of /nix/store (the squashfs
    # image) to make this a live CD.
    "/nix/.ro-store" = mkImageMediaOverride
    "/nix/.ro-store" = lib.mkImageMediaOverride
      { fsType = "squashfs";
        device = "/iso/nix-store.squashfs";
        options = [ "loop" ];
        neededForBoot = true;
      };

    "/nix/.rw-store" = mkImageMediaOverride
    "/nix/.rw-store" = lib.mkImageMediaOverride
      { fsType = "tmpfs";
        options = [ "mode=0755" ];
        neededForBoot = true;
      };

    "/nix/store" = mkImageMediaOverride
    "/nix/store" = lib.mkImageMediaOverride
      { fsType = "overlay";
        device = "overlay";
        options = [
@@ -760,11 +756,11 @@ in
        message = "BIOS boot is only supported on x86-based architectures.";
      }
      {
        assertion = !(stringLength config.isoImage.volumeID > 32);
        assertion = !(lib.stringLength config.isoImage.volumeID > 32);
        # https://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
        # Volume Identifier can only be 32 bytes
        message = let
          length = stringLength config.isoImage.volumeID;
          length = lib.stringLength config.isoImage.volumeID;
          howmany = toString length;
          toomany = toString (length - 32);
        in
@@ -777,7 +773,7 @@ in
    boot.loader.grub.enable = false;

    environment.systemPackages =  [ grubPkgs.grub2 grubPkgs.grub2_efi ]
      ++ optional (config.isoImage.makeBiosBootable) pkgs.syslinux
      ++ lib.optional (config.isoImage.makeBiosBootable) pkgs.syslinux
    ;

    # In stage 1 of the boot, mount the CD as the root FS by label so
@@ -803,7 +799,7 @@ in
    # script and the top-level system configuration directory.
    isoImage.storeContents =
      [ config.system.build.toplevel ] ++
      optional config.isoImage.includeSystemBuildDependencies
      lib.optional config.isoImage.includeSystemBuildDependencies
        config.system.build.toplevel.drvPath;

    # Individual files to be included on the CD, outside of the Nix
@@ -819,7 +815,7 @@ in
        { source = pkgs.writeText "version" config.system.nixos.label;
          target = "/version.txt";
        }
      ] ++ optionals (config.isoImage.makeBiosBootable) [
      ] ++ lib.optionals (config.isoImage.makeBiosBootable) [
        { source = config.isoImage.splashImage;
          target = "/isolinux/background.png";
        }
@@ -833,7 +829,7 @@ in
        { source = "${pkgs.syslinux}/share/syslinux";
          target = "/isolinux";
        }
      ] ++ optionals config.isoImage.makeEfiBootable [
      ] ++ lib.optionals config.isoImage.makeEfiBootable [
        { source = efiImg;
          target = "/boot/efi.img";
        }
@@ -846,11 +842,11 @@ in
        { source = config.isoImage.efiSplashImage;
          target = "/EFI/boot/efi-background.png";
        }
      ] ++ optionals (config.boot.loader.grub.memtest86.enable && config.isoImage.makeBiosBootable) [
      ] ++ lib.optionals (config.boot.loader.grub.memtest86.enable && config.isoImage.makeBiosBootable) [
        { source = "${pkgs.memtest86plus}/memtest.bin";
          target = "/boot/memtest.bin";
        }
      ] ++ optionals (config.isoImage.grubTheme != null) [
      ] ++ lib.optionals (config.isoImage.grubTheme != null) [
        { source = config.isoImage.grubTheme;
          target = "/EFI/boot/grub-theme";
        }
@@ -866,10 +862,10 @@ in
      syslinux = if config.isoImage.makeBiosBootable then pkgs.syslinux else null;
      squashfsContents = config.isoImage.storeContents;
      squashfsCompression = config.isoImage.squashfsCompression;
    } // optionalAttrs (config.isoImage.makeUsbBootable && config.isoImage.makeBiosBootable) {
    } // lib.optionalAttrs (config.isoImage.makeUsbBootable && config.isoImage.makeBiosBootable) {
      usbBootable = true;
      isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
    } // optionalAttrs config.isoImage.makeEfiBootable {
    } // lib.optionalAttrs config.isoImage.makeEfiBootable {
      efiBootable = true;
      efiBootImage = "boot/efi.img";
    });
+53 −56
Original line number Diff line number Diff line
{ config, lib, pkgs, ... }:

with lib;

let

  name = "mpd";
@@ -12,11 +9,11 @@ let

  credentialsPlaceholder = (creds:
    let
      placeholders = (imap0
        (i: c: ''password "{{password-${toString i}}}@${concatStringsSep "," c.permissions}"'')
      placeholders = (lib.imap0
        (i: c: ''password "{{password-${toString i}}}@${lib.concatStringsSep "," c.permissions}"'')
        creds);
    in
      concatStringsSep "\n" placeholders);
      lib.concatStringsSep "\n" placeholders);

  mpdConf = pkgs.writeText "mpd.conf" ''
    # This file was automatically generated by NixOS. Edit mpd's configuration
@@ -31,16 +28,16 @@ let
    state_file          "${cfg.dataDir}/state"
    sticker_file        "${cfg.dataDir}/sticker.sql"

    ${optionalString (cfg.network.listenAddress != "any") ''bind_to_address "${cfg.network.listenAddress}"''}
    ${optionalString (cfg.network.port != 6600)  ''port "${toString cfg.network.port}"''}
    ${optionalString (cfg.fluidsynth) ''
    ${lib.optionalString (cfg.network.listenAddress != "any") ''bind_to_address "${cfg.network.listenAddress}"''}
    ${lib.optionalString (cfg.network.port != 6600)  ''port "${toString cfg.network.port}"''}
    ${lib.optionalString (cfg.fluidsynth) ''
      decoder {
              plugin "fluidsynth"
              soundfont "${pkgs.soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2"
      }
    ''}

    ${optionalString (cfg.credentials != []) (credentialsPlaceholder cfg.credentials)}
    ${lib.optionalString (cfg.credentials != []) (credentialsPlaceholder cfg.credentials)}

    ${cfg.extraConfig}
  '';
@@ -53,16 +50,16 @@ in {

    services.mpd = {

      enable = mkOption {
        type = types.bool;
      enable = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = ''
          Whether to enable MPD, the music player daemon.
        '';
      };

      startWhenNeeded = mkOption {
        type = types.bool;
      startWhenNeeded = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = ''
          If set, {command}`mpd` is socket-activated; that
@@ -71,10 +68,10 @@ in {
        '';
      };

      musicDirectory = mkOption {
        type = with types; either path (strMatching "(http|https|nfs|smb)://.+");
      musicDirectory = lib.mkOption {
        type = with lib.types; either path (strMatching "(http|https|nfs|smb)://.+");
        default = "${cfg.dataDir}/music";
        defaultText = literalExpression ''"''${dataDir}/music"'';
        defaultText = lib.literalExpression ''"''${dataDir}/music"'';
        description = ''
          The directory or NFS/SMB network share where MPD reads music from. If left
          as the default value this directory will automatically be created before
@@ -83,10 +80,10 @@ in {
        '';
      };

      playlistDirectory = mkOption {
        type = types.path;
      playlistDirectory = lib.mkOption {
        type = lib.types.path;
        default = "${cfg.dataDir}/playlists";
        defaultText = literalExpression ''"''${dataDir}/playlists"'';
        defaultText = lib.literalExpression ''"''${dataDir}/playlists"'';
        description = ''
          The directory where MPD stores playlists. If left as the default value
          this directory will automatically be created before the MPD server starts,
@@ -95,8 +92,8 @@ in {
        '';
      };

      extraConfig = mkOption {
        type = types.lines;
      extraConfig = lib.mkOption {
        type = lib.types.lines;
        default = "";
        description = ''
          Extra directives added to to the end of MPD's configuration file,
@@ -106,8 +103,8 @@ in {
        '';
      };

      dataDir = mkOption {
        type = types.path;
      dataDir = lib.mkOption {
        type = lib.types.path;
        default = "/var/lib/${name}";
        description = ''
          The directory where MPD stores its state, tag cache, playlists etc. If
@@ -117,22 +114,22 @@ in {
        '';
      };

      user = mkOption {
        type = types.str;
      user = lib.mkOption {
        type = lib.types.str;
        default = name;
        description = "User account under which MPD runs.";
      };

      group = mkOption {
        type = types.str;
      group = lib.mkOption {
        type = lib.types.str;
        default = name;
        description = "Group account under which MPD runs.";
      };

      network = {

        listenAddress = mkOption {
          type = types.str;
        listenAddress = lib.mkOption {
          type = lib.types.str;
          default = "127.0.0.1";
          example = "any";
          description = ''
@@ -141,8 +138,8 @@ in {
          '';
        };

        port = mkOption {
          type = types.port;
        port = lib.mkOption {
          type = lib.types.port;
          default = 6600;
          description = ''
            This setting is the TCP port that is desired for the daemon to get assigned
@@ -152,33 +149,33 @@ in {

      };

      dbFile = mkOption {
        type = types.nullOr types.str;
      dbFile = lib.mkOption {
        type = lib.types.nullOr lib.types.str;
        default = "${cfg.dataDir}/tag_cache";
        defaultText = literalExpression ''"''${dataDir}/tag_cache"'';
        defaultText = lib.literalExpression ''"''${dataDir}/tag_cache"'';
        description = ''
          The path to MPD's database. If set to `null` the
          parameter is omitted from the configuration.
        '';
      };

      credentials = mkOption {
        type = types.listOf (types.submodule {
      credentials = lib.mkOption {
        type = lib.types.listOf (lib.types.submodule {
          options = {
            passwordFile = mkOption {
              type = types.path;
            passwordFile = lib.mkOption {
              type = lib.types.path;
              description = ''
                Path to file containing the password.
              '';
            };
            permissions = let
              perms = ["read" "add" "control" "admin"];
            in mkOption {
              type = types.listOf (types.enum perms);
            in lib.mkOption {
              type = lib.types.listOf (lib.types.enum perms);
              default = [ "read" ];
              description = ''
                List of permissions that are granted with this password.
                Permissions can be "${concatStringsSep "\", \"" perms}".
                Permissions can be "${lib.concatStringsSep "\", \"" perms}".
              '';
            };
          };
@@ -193,8 +190,8 @@ in {
        ];
      };

      fluidsynth = mkOption {
        type = types.bool;
      fluidsynth = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = ''
          If set, add fluidsynth soundfont and configure the plugin.
@@ -207,31 +204,31 @@ in {

  ###### implementation

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {

    # install mpd units
    systemd.packages = [ pkgs.mpd ];

    systemd.sockets.mpd = mkIf cfg.startWhenNeeded {
    systemd.sockets.mpd = lib.mkIf cfg.startWhenNeeded {
      wantedBy = [ "sockets.target" ];
      listenStreams = [
        ""  # Note: this is needed to override the upstream unit
        (if pkgs.lib.hasPrefix "/" cfg.network.listenAddress
          then cfg.network.listenAddress
          else "${optionalString (cfg.network.listenAddress != "any") "${cfg.network.listenAddress}:"}${toString cfg.network.port}")
          else "${lib.optionalString (cfg.network.listenAddress != "any") "${cfg.network.listenAddress}:"}${toString cfg.network.port}")
      ];
    };

    systemd.services.mpd = {
      wantedBy = optional (!cfg.startWhenNeeded) "multi-user.target";
      wantedBy = lib.optional (!cfg.startWhenNeeded) "multi-user.target";

      preStart =
        ''
          set -euo pipefail
          install -m 600 ${mpdConf} /run/mpd/mpd.conf
        '' + optionalString (cfg.credentials != [])
        (concatStringsSep "\n"
          (imap0
        '' + lib.optionalString (cfg.credentials != [])
        (lib.concatStringsSep "\n"
          (lib.imap0
            (i: c: ''${pkgs.replace-secret}/bin/replace-secret '{{password-${toString i}}}' '${c.passwordFile}' /run/mpd/mpd.conf'')
            cfg.credentials));

@@ -242,13 +239,13 @@ in {
          ExecStart = [ "" "${pkgs.mpd}/bin/mpd --systemd /run/mpd/mpd.conf" ];
          RuntimeDirectory = "mpd";
          StateDirectory = []
            ++ optionals (cfg.dataDir == "/var/lib/${name}") [ name ]
            ++ optionals (cfg.playlistDirectory == "/var/lib/${name}/playlists") [ name "${name}/playlists" ]
            ++ optionals (cfg.musicDirectory == "/var/lib/${name}/music")        [ name "${name}/music" ];
            ++ lib.optionals (cfg.dataDir == "/var/lib/${name}") [ name ]
            ++ lib.optionals (cfg.playlistDirectory == "/var/lib/${name}/playlists") [ name "${name}/playlists" ]
            ++ lib.optionals (cfg.musicDirectory == "/var/lib/${name}/music")        [ name "${name}/music" ];
        };
    };

    users.users = optionalAttrs (cfg.user == name) {
    users.users = lib.optionalAttrs (cfg.user == name) {
      ${name} = {
        inherit uid;
        group = cfg.group;
@@ -258,7 +255,7 @@ in {
      };
    };

    users.groups = optionalAttrs (cfg.group == name) {
    users.groups = lib.optionalAttrs (cfg.group == name) {
      ${name}.gid = gid;
    };
  };
+82 −80

File changed.

Preview size limit exceeded, changes collapsed.

Loading