diff --git a/README.md b/README.md index c056a52..1071d7e 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,34 @@ The `zwift.sh` script will update zwift by checking for new image versions on ev There is a github action in place that will update zwift on a scheduled basis and publish new versions to docker hub. +## How can I install this on NixOS? + +To use the NixOS module, configure your flake.nix: + +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + zwift.url = "github:netbrain/zwift"; + }; + + outputs = { nixpkgs, zwift, ... }: { + nixosConfigurations."«hostname»" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ zwift.nixosModules.zwift ./configuration.nix ]; + }; + }; +} +``` + +Then enable the module in your NixOS configuration: + +```nix +{ + programs.zwift.enable = true; +} +``` + ## Sponsors 💖 These are our really cool sponsors! diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ca4a6b9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1734435836, + "narHash": "sha256-kMBQ5PRiFLagltK0sH+08aiNt3zGERC2297iB6vrvlU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4989a246d7a390a859852baddb1013f825435cee", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..17fcac4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "Easily zwift on linux"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = + { nixpkgs, self }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in + { + nixosModules = { + zwift = + { config, lib, ... }: + { + options.programs.zwift.enable = lib.mkEnableOption "zwift on linux"; + + config = lib.mkIf config.programs.zwift.enable { + virtualisation.podman.enable = true; + environment.systemPackages = [ self.packages.x86_64-linux.zwift ]; + }; + }; + default = self.nixosModules.zwift; + }; + + packages.x86_64-linux = { + zwift = pkgs.stdenv.mkDerivation rec { + pname = "zwift"; + version = "0-unstable"; + + src = ./.; + + nativeBuildInputs = [ pkgs.copyDesktopItems ]; + + installPhase = '' + runHook preInstall + install -Dm755 zwift.sh -T $out/bin/${pname} + install -Dm644 $src/assets/hicolor/scalable/apps/Zwift\ Logogram.svg \ + -T $out/share/icons/hicolor/scalable/apps/zwift.svg + runHook postInstall + ''; + + desktopItems = [ "assets/Zwift.desktop" ]; + }; + default = self.packages.x86_64-linux.zwift; + }; + }; +}