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

Merge master into staging-next

parents ab6f1d83 bcd43fb1
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -374,6 +374,50 @@ mkPythonMetaPackage {
}
```

#### `mkPythonEditablePackage` function {#mkpythoneditablepackage-function}

When developing Python packages it's common to install packages in [editable mode](https://setuptools.pypa.io/en/latest/userguide/development_mode.html).
Like `mkPythonMetaPackage` this function exists to create an otherwise empty package, but also containing a pointer to an impure location outside the Nix store that can be changed without rebuilding.

The editable root is passed as a string. Normally `.pth` files contains absolute paths to the mutable location. This isn't always ergonomic with Nix, so environment variables are expanded at runtime.
This means that a shell hook setting up something like a `$REPO_ROOT` variable can be used as the relative package root.

As an implementation detail, the [PEP-518](https://peps.python.org/pep-0518/) `build-system` specified won't be used, but instead the editable package will be built using [hatchling](https://pypi.org/project/hatchling/).
The `build-system`'s provided will instead become runtime dependencies of the editable package.

Note that overriding packages deeper in the dependency graph _can_ work, but it's not the primary use case and overriding existing packages can make others break in unexpected ways.

``` nix
{ pkgs ? import <nixpkgs> { } }:

let
  pyproject = pkgs.lib.importTOML ./pyproject.toml;

  myPython = pkgs.python.override {
    self = myPython;
    packageOverrides = pyfinal: pyprev: {
      # An editable package with a script that loads our mutable location
      my-editable = pyfinal.mkPythonEditablePackage {
        # Inherit project metadata from pyproject.toml
        pname = pyproject.project.name;
        inherit (pyproject.project) version;

        # The editable root passed as a string
        root = "$REPO_ROOT/src"; # Use environment variable expansion at runtime

        # Inject a script (other PEP-621 entrypoints are also accepted)
        inherit (pyproject.project) scripts;
      };
    };
  };

  pythonEnv =  testPython.withPackages (ps: [ ps.my-editable ]);

in pkgs.mkShell {
  packages = [ pythonEnv ];
}
```

#### `python.buildEnv` function {#python.buildenv-function}

Python environments can be created using the low-level `pkgs.buildEnv` function.
+0 −6
Original line number Diff line number Diff line
@@ -5813,12 +5813,6 @@
    githubId = 8146736;
    name = "Florentin Eckl";
  };
  eclairevoyant = {
    email = "contactmeongithubinstead@proton.me";
    github = "eclairevoyant";
    githubId = 848000;
    name = "éclairevoyant";
  };
  edanaher = {
    email = "nixos@edanaher.net";
    github = "edanaher";
+0 −1
Original line number Diff line number Diff line
@@ -942,7 +942,6 @@ with lib.maintainers;
  steam = {
    members = [
      atemu
      eclairevoyant
      k900
      mkg20001
    ];
+10 −6
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@ let
  cfg = config.power.ups;
  defaultPort = 3493;

  envVars = {
    NUT_CONFPATH = "/etc/nut";
    NUT_STATEPATH = "/var/lib/nut";
  };

  nutFormat = {

    type = with lib.types; let
@@ -493,7 +498,9 @@ in
      })
    ];

    # For interactive use.
    environment.systemPackages = [ pkgs.nut ];
    environment.variables = envVars;

    networking.firewall = lib.mkIf cfg.openFirewall {
      allowedTCPPorts =
@@ -517,8 +524,7 @@ in
        ExecReload = "${pkgs.nut}/sbin/upsmon -c reload";
        LoadCredential = lib.mapAttrsToList (name: monitor: "upsmon_password_${name}:${monitor.passwordFile}") cfg.upsmon.monitor;
      };
      environment.NUT_CONFPATH = "/etc/nut";
      environment.NUT_STATEPATH = "/var/lib/nut";
      environment = envVars;
    };

    systemd.services.upsd = let
@@ -537,8 +543,7 @@ in
        ExecReload = "${pkgs.nut}/sbin/upsd -c reload";
        LoadCredential = lib.mapAttrsToList (name: user: "upsdusers_password_${name}:${user.passwordFile}") cfg.users;
      };
      environment.NUT_CONFPATH = "/etc/nut";
      environment.NUT_STATEPATH = "/var/lib/nut";
      environment = envVars;
      restartTriggers = [
        config.environment.etc."nut/upsd.conf".source
      ];
@@ -555,8 +560,7 @@ in
        # TODO: replace 'root' by another username.
        ExecStart = "${pkgs.nut}/bin/upsdrvctl -u root start";
      };
      environment.NUT_CONFPATH = "/etc/nut";
      environment.NUT_STATEPATH = "/var/lib/nut";
      environment = envVars;
      restartTriggers = [
        config.environment.etc."nut/ups.conf".source
      ];
+2 −2
Original line number Diff line number Diff line
@@ -97,14 +97,14 @@ in
      # home.
      tmpfiles.settings.home-directories = lib.mapAttrs' (
        username: opts:
        lib.nameValuePair opts.home {
        lib.nameValuePair (toString opts.home) {
          d = {
            mode = opts.homeMode;
            user = username;
            inherit (opts) group;
          };
        }
      ) (lib.filterAttrs (_username: opts: opts.home != "/var/empty") userCfg.users);
      ) (lib.filterAttrs (_username: opts: opts.createHome && opts.home != "/var/empty") userCfg.users);

      services.userborn = {
        wantedBy = [ "sysinit.target" ];
Loading