Skip to content

Commit

Permalink
Refactor nix flake, based on overriding nixpkgs
Browse files Browse the repository at this point in the history
Now that umu-launcher is being maintained in nixpkgs, it can be used as
a starting point for the nix package here. We just need to override a
few things, such as the `src`, and handle any changes that have not yet
made it into a release build.

The opportunity has been taken to clean up that package-args API:
- Renamed `truststore` to `withTruststore` with a warning.
- `cbor2` wasn't working, warn when it is used.
- Added `withDeltaUpdates`

Breaking changes:
- The umu-launcher package in the overlay is no longer the unwrapped
  package (previously in `umu-launcher.nix`).
- The derivation attrs for various packages are re-written from scratch,
  likely breaking users' custom overrides.

Non-breaking changes:
- The umu & umu-run packages have effectively been renamed umu-launcher.
- The flake outputs for all systems supported by the nixpkgs package.
- The package version now defaults to the flake's git revision.
  • Loading branch information
MattSturgeon committed Jan 31, 2025
1 parent b887d4a commit 8cb9879
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 138 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,30 @@ and in your `configuration.nix`
{inputs, pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) system;
umu = inputs.umu.packages.${system}.umu.override {
version = inputs.umu.shortRev;
truststore = true;
cbor2 = true;
};
umu-launcher = inputs.umu.packages.${system}.default;
in
{
environment.systemPackages = [ umu ];
environment.systemPackages = [ umu-launcher ];
}
```
> [!NOTE]
> truststore and cbor2 (for delta updates) are optional dependency which are enabled by default if you want to keep it that way you can remove the `truststore = true; cbor2 = true;` part

> [!TIP]
> You can override `withTruststore` and/or `withDeltaUpdates` to disable optional dependencies.
>
> ```nix
> umu-launcher = inputs.umu.packages.${system}.default.override {
> withTruststore = false;
> withDeltaUpdates = false;
> };
> ```
>
> - `withTruststore` adds dependencies that allow using the system trust store
> - `withDeltaUpdates` adds dependencies that enable "delta updates" to Proton builds
>
> Both options are true by default.
> [!NOTE]
> The example above relies on having your flake's `inputs` passed through to your nixos configuration.
> The examples above rely on having your flake's `inputs` passed through to your nixos configuration.
> This can be done with `specialArgs` or `_module.args`, e.g:
> ```nix
> {
Expand Down
22 changes: 0 additions & 22 deletions packaging/nix/combine.nix

This file was deleted.

57 changes: 29 additions & 28 deletions packaging/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,44 @@
self,
nixpkgs,
}: let
umu-launcher-src = builtins.toPath "${self}/../../";
inherit (nixpkgs) lib;

pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [self.overlays.default];
};
# Utility function for producing consistent rename warning messages
rename = old: new: lib.warn "`${old}` has been renamed to `${new}`";

version = "1.1.4";
in {
overlays.default = final: prev: let
py = prev.python3;
in {
umu-launcher = final.callPackage ./umu-launcher.nix {
inherit version;
umu-launcher = umu-launcher-src;
pyth1 = py;
};
# Supported platforms & package sets
platforms = lib.platforms.linux;
supportedPkgs = lib.filterAttrs (system: _: builtins.elem system platforms) nixpkgs.legacyPackages;

umu-run = final.callPackage ./umu-run.nix {
inherit version;
package = final.umu-launcher;
# Use the current revision for the default version
version = self.dirtyShortRev or self.shortRev or self.lastModifiedDate;
in {
overlays.default = final: prev: {
umu-launcher = final.callPackage ./package.nix {
inherit (prev) umu-launcher;
};

umu = final.callPackage ./combine.nix {
umu-launcher-unwrapped = final.callPackage ./unwrapped.nix {
inherit (prev) umu-launcher-unwrapped;
inherit version;
env = final.umu-run;
package = final.umu-launcher;
truststore = true;
cbor2 = true;
};
# Deprecated in https://github.com/Open-Wine-Components/umu-launcher/pull/345 (2025-01-27)
umu = rename "umu" "umu-launcher" final.umu-launcher;
umu-run = rename "umu-run" "umu-launcher" final.umu-launcher;
};

formatter = builtins.mapAttrs (system: pkgs: pkgs.alejandra) nixpkgs.legacyPackages;

packages.x86_64-linux = {
inherit (pkgs) umu;
default = self.packages.x86_64-linux.umu;
};
packages =
builtins.mapAttrs (system: pkgs: rec {
default = umu-launcher;
inherit
(pkgs.extend self.overlays.default)
umu-launcher
umu-launcher-unwrapped
;
# Deprecated in https://github.com/Open-Wine-Components/umu-launcher/pull/345 (2025-01-27)
umu = rename "packages.${system}.umu" "packages.${system}.umu-launcher" umu-launcher;
})
supportedPkgs;
};
}
44 changes: 44 additions & 0 deletions packaging/nix/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
# Dependencies
lib,
umu-launcher,
umu-launcher-unwrapped,
# Public API
version ? null,
withTruststore ? args.truststore or true,
withDeltaUpdates ? true,
# Freeform args
...
} @ args: let
# Args not handled here; to be passed to the nixpkgs package
# E.g. to support overriding `extraPkgs` or `extraLibraries`
# NOTE: All known args must be removed here
unknownArgs = builtins.removeAttrs args [
"lib"
"umu-launcher"
"umu-launcher-unwrapped"
"version"
"withTruststore"
"withDeltaUpdates"
"truststore"
"cbor2"
];

# Overrides for umu-launcher-unwrapped
overrides =
# Warnings added in https://github.com/Open-Wine-Components/umu-launcher/pull/345 (2025-01-27)
lib.warnIf (args ? truststore) "umu-launcher: the argument `truststore` has been renamed to `withTruststore`."
lib.warnIf (args ? cbor2) "umu-launcher: the argument `cbor2` has never had any effect. The new argument `withDeltaUpdates` should be used instead."
lib.optionalAttrs (args ? version) {inherit version;}
// lib.optionalAttrs (args ? withTruststore || args ? truststore) {inherit withTruststore;}
// lib.optionalAttrs (args ? withDeltaUpdates) {inherit withDeltaUpdates;};
in
umu-launcher.override (
unknownArgs
// {
umu-launcher-unwrapped =
if overrides == {}
then umu-launcher-unwrapped
else umu-launcher-unwrapped.override overrides;
}
)
61 changes: 0 additions & 61 deletions packaging/nix/umu-launcher.nix

This file was deleted.

18 changes: 0 additions & 18 deletions packaging/nix/umu-run.nix

This file was deleted.

52 changes: 52 additions & 0 deletions packaging/nix/unwrapped.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
# Dependencies
lib,
umu-launcher-unwrapped,
python3Packages,
rustPlatform,
cargo,
zstd,
# Public API
version,
withTruststore ? true,
withDeltaUpdates ? true,
}:
umu-launcher-unwrapped.overridePythonAttrs (prev: {
src = ../../.;
inherit version;

# The nixpkgs patches (in `prev.patches`) are not needed anymore
# - no-umu-version-json.patch was resolved in:
# https://github.com/Open-Wine-Components/umu-launcher/pull/289
# - The other is backporting:
# https://github.com/Open-Wine-Components/umu-launcher/pull/343
patches = [
# Remove `umu-vendored` from the `all` target
# This causes an error when building vendored dependencies:
# python3 -m pip install urllib3 -t builddir
# => No module named pip
./0-Makefile-no-vendor.patch
];

nativeBuildInputs =
(prev.nativeBuildInputs or [])
++ [
rustPlatform.cargoSetupHook
cargo
];

propagatedBuildInputs =
(prev.propagatedBuildInputs or [])
++ lib.optionals withTruststore [
python3Packages.truststore
]
++ lib.optionals withDeltaUpdates [
python3Packages.cbor2
python3Packages.xxhash
zstd
];

cargoDeps = rustPlatform.importCargoLock {
lockFile = ../../Cargo.lock;
};
})

0 comments on commit 8cb9879

Please sign in to comment.