diff --git a/default.nix b/default.nix deleted file mode 100644 index 2b625713..00000000 --- a/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -( - import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - {src = ./.;} -) -.defaultNix diff --git a/flake.lock b/flake.lock index 427168b3..5d0d3590 100644 --- a/flake.lock +++ b/flake.lock @@ -1,40 +1,9 @@ { "nodes": { - "flake-compat": { - "locked": { - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "revCount": 57, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" - } - }, "flake-utils": { "inputs": { "systems": "systems" }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, "locked": { "lastModified": 1701680307, "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", @@ -51,40 +20,26 @@ }, "nixpkgs": { "locked": { - "lastModified": 1698370541, - "narHash": "sha256-/mQQPmcRbpWsGgFi4vj4Bz2N2Yos4Vr+ru+v3qyEqp0=", + "lastModified": 1703499205, + "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f1775e6477c6e342bbbdecf363f9f5821d7fd3e4", + "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1702151865, - "narHash": "sha256-9VAt19t6yQa7pHZLDbil/QctAgVsA66DLnzdRGqDisg=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "666fc80e7b2afb570462423cb0e1cf1a3a34fedd", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "pnpm2nix": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2" + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1702270329, @@ -102,8 +57,6 @@ }, "root": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "pnpm2nix": "pnpm2nix" } @@ -122,21 +75,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 43479f79..7f5e4ee5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,41 +2,31 @@ description = "Flake for owmods-cli and owmods-gui"; inputs = { - flake-utils.url = "github:numtide/flake-utils"; - flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; - pnpm2nix.url = "github:nzbr/pnpm2nix-nzbr"; - nixpkgs.url = "github:NixOS/nixpkgs/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + pnpm2nix = { + url = "github:nzbr/pnpm2nix-nzbr"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, - flake-utils, - flake-compat, nixpkgs, pnpm2nix, - }: - flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = (import nixpkgs) { - inherit system; - overlays = [self.overlay.owmods pnpm2nix.overlays.default]; - }; - in rec { - # For `nix build` & `nix run`: - packages = rec { - owmods-cli = pkgs.owmods-cli; - owmods-gui = pkgs.owmods-gui; - default = pkgs.owmods-cli; - }; - } - ) - // { - formatter."x86_64-linux" = nixpkgs.legacyPackages."x86_64-linux".alejandra; - devShell."x86_64-linux" = (import ./nix/shell.nix) {inherit nixpkgs;}; - overlay.owmods = import ./nix/overlay.nix; - nixosModules.owmods = import ./nix/modules/nixos.nix; - homeManagerModules.owmods = import ./nix/modules/hm.nix; - }; + }: let + forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + pkgsFor = system: + (import nixpkgs) { + inherit system; + overlays = [self.overlays.default pnpm2nix.overlays.default]; + }; + in { + packages = forAllSystems (system: with pkgsFor system; {inherit owmods-cli owmods-gui;}); + overlays.default = import ./nix/overlay.nix; + + formatter = forAllSystems (system: (pkgsFor system).alejandra); + devShells = forAllSystems (system: {default = import ./nix/shell.nix {pkgs = pkgsFor system;};}); + }; nixConfig = { extra-substituters = ["https://ow-mods.cachix.org"]; diff --git a/nix/README.md b/nix/README.md index f1a86687..7f24ea07 100644 --- a/nix/README.md +++ b/nix/README.md @@ -1,97 +1,34 @@ -# NixOS Installation +# Usage with Nix -You can either install using the package in [nixpkgs](https://search.nixos.org/packages?channel=unstable&show=owmods-cli&from=0&size=50&sort=relevance&type=packages&query=owmods) or by getting it from the flake. -## Without Flakes +Currently, `owmods-cli` is in nixpkgs. ([Nixpkgs status](https://search.nixos.org/packages?channel=unstable&type=packages&query=owmod)) -This flake comes with [flake-compat](https://github.com/edolstra/flake-compat), which makes it usable in systems that use flakes, or not. +Alternatively, you can get the latest version from this repo. + +## Flakes + +The flake provides an overlay and the packages `owmods-cli` and `owmods-gui`. +```nix +ow-mod-man = { + url = "github:ow-mods/ow-mod-man/dev"; + inputs.nixpkgs.follows = "nixpkgs"; +}; +``` +You can then reference `ow-mod-man.packages..owmods-`, or use the overlay, for example: +```nix +nixpkgs.overlays = [ inputs.ow-mod-man.overlays.default ] +``` + +## Without flakes +If you can't or don't want to use flakes, you can use [flake-compat](https://github.com/edolstra/flake-compat). -To install it, edit you NixOS/Home Manager configuration with: ```nix -{ pkgs, lib, ... }: let - ow-mod-man = import (builtins.fetchGit { + flake-compat = import (fetchTarball "https://github.com/edolstra/flake-compat/archive/master.tar.gz"); + src = fetchGit { url = "https://github.com/ow-mods/ow-mod-man.git"; - # You can choose which version by changing the ref ref = "dev"; - }); -in -{ - imports = [ - # For NixOS - ow-mod-man.nixosModules.owmods - # For Home Manager - ow-mod-man.homeManagerModules.owmods - ]; - - # Unsafe dependency of the gui version - permittedInsecurePackages = [ "openssl-1.1.1w" ]; - - - # To enable the cli version - programs.owmods-cli.enable = true; - # To enable the gui version - programs.owmods-gui.enable = true; -} -``` - -## Using Flakes - -If you are already using flakes, this is the recommended method, what you need to add is: - -- In your flake.nix: -```nix -{ - inputs.ow-mod-man = { - url = "github:ow-mods/ow-mod-man/dev"; - inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { ow-mod-man }: - # You need to add the ow-mod-man overlay to your packages - let pkgs = import nixpkgs { - inherit system; - config = { - # Needed for the gui version - permittedInsecurePackages = [ "openssl-1.1.1w" ]; - }; - # Needed to be able to use the packages - overlays = [ ow-mod-man.overlay.owmods ]; - }; - in { - homeConfigurations = { - userA = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - # For your home.nix - modules = [ ow-mod-man.homeManagerModules.owmods ]; - }; - }; + ow-mod-man = (flake-compat { inherit src; }).defaultNix; +in ow-mod-man.packages..owmods- - nixosConfigurations = { - systemA = lib.nixosSystem { - inherit system; - inherit pkgs; - # For your configuration.nix - modules = [ ow-mod-man.nixosModules.owmods ]; - }; - }; -} -``` -- In your configuration.nix: -```nix -{ pkgs, inputs, ... }: -{ - # To enable the cli version - programs.owmods-cli.enable = true; - # To enable the gui version - programs.owmods-gui.enable = true; -} -``` -- In your home.nix: -```nix -{ pkgs, inputs, ... }: -{ - # To enable the cli version - programs.owmods-cli.enable = true; - # To enable the gui version - programs.owmods-gui.enable = true; -} -``` +``` \ No newline at end of file diff --git a/nix/modules/hm.nix b/nix/modules/hm.nix deleted file mode 100644 index 4343c3ee..00000000 --- a/nix/modules/hm.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - lib, - pkgs, - config, - ... -}: -with lib; let - cli-cfg = config.programs.owmods-cli; - gui-cfg = config.programs.owmods-gui; -in { - options.programs = { - owmods-cli = { - enable = mkEnableOption "owmods-cli program"; - }; - owmods-gui = { - enable = mkEnableOption "owmods-gui program"; - }; - }; - - config = mkIf (cli-cfg.enable || gui-cfg.enable) ( - mkMerge [ - { - home.packages = [ - (mkIf cli-cfg.enable (pkgs.owmods-cli)) - (mkIf gui-cfg.enable (pkgs.owmods-gui)) - pkgs.mono - ]; - } - ] - ); -} diff --git a/nix/modules/nixos.nix b/nix/modules/nixos.nix deleted file mode 100644 index 8d75fb3d..00000000 --- a/nix/modules/nixos.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - lib, - pkgs, - config, - ... -}: -with lib; let - cli-cfg = config.programs.owmods-cli; - gui-cfg = config.programs.owmods-gui; -in { - options.programs = { - owmods-cli = { - enable = mkEnableOption "owmods-cli program"; - }; - owmods-gui = { - enable = mkEnableOption "owmods-gui program"; - }; - }; - - config = mkIf (cli-cfg.enable || gui-cfg.enable) ( - mkMerge [ - { - environment.systemPackages = [ - (mkIf cli-cfg.enable (pkgs.owmods-cli)) - (mkIf gui-cfg.enable (pkgs.owmods-gui)) - pkgs.mono - ]; - } - ] - ); -} diff --git a/nix/overlay.nix b/nix/overlay.nix index b26c6ede..a70fff13 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,4 +1,4 @@ final: prev: { - owmods-cli = final.pkgs.callPackage ./owmods-cli.nix {}; - owmods-gui = final.pkgs.callPackage ./owmods-gui.nix {}; + owmods-cli = final.callPackage ./owmods-cli.nix {}; + owmods-gui = final.callPackage ./owmods-gui.nix {}; } diff --git a/nix/owmods-cli.nix b/nix/owmods-cli.nix index 418270a4..1a799fec 100644 --- a/nix/owmods-cli.nix +++ b/nix/owmods-cli.nix @@ -6,12 +6,28 @@ fetchFromGitHub, installShellFiles, rustPlatform, + makeWrapper, + mono, + wrapWithMono ? true, }: rustPlatform.buildRustPackage rec { pname = "owmods-cli"; version = "0.12.0"; - src = ../.; + # Prevent unneeded rebuilds + src = with lib.fileset; + toSource { + root = ../.; + fileset = unions [ + ../.cargo + ../owmods_gui + ../owmods_cli + ../owmods_core + ../xtask + ../Cargo.toml + ../Cargo.lock + ]; + }; cargoLock = { lockFile = ../Cargo.lock; @@ -20,7 +36,7 @@ rustPlatform.buildRustPackage rec { nativeBuildInputs = [ pkg-config installShellFiles - ]; + ] ++ lib.optional wrapWithMono makeWrapper; buildInputs = [ openssl @@ -34,6 +50,7 @@ rustPlatform.buildRustPackage rec { installManPage dist/cli/man/* installShellCompletion --cmd owmods \ dist/cli/completions/owmods.{bash,fish,zsh} + ${lib.optionalString wrapWithMono "wrapProgram $out/bin/${meta.mainProgram} --prefix PATH : '${mono}/bin'"} ''; meta = with lib; { diff --git a/nix/owmods-gui.nix b/nix/owmods-gui.nix index 19f2bbf5..a82b74e4 100644 --- a/nix/owmods-gui.nix +++ b/nix/owmods-gui.nix @@ -16,12 +16,27 @@ copyDesktopItems, rustPlatform, mkPnpmPackage, + mono, + wrapWithMono ? true, }: rustPlatform.buildRustPackage rec { pname = "owmods-gui"; version = "0.12.0"; - src = ../.; + # Prevent unneeded rebuilds + src = with lib.fileset; + toSource { + root = ../.; + fileset = unions [ + ../.cargo + ../owmods_gui + ../owmods_cli + ../owmods_core + ../xtask + ../Cargo.toml + ../Cargo.lock + ]; + }; cargoLock = { lockFile = ../Cargo.lock; @@ -44,8 +59,10 @@ rustPlatform.buildRustPackage rec { buildAndTestSubdir = "owmods_gui/backend"; + postFixup = lib.optionalString wrapWithMono "gappsWrapperArgs+=(--prefix PATH : '${mono}/bin')"; + postPatch = let - frontend = mkPnpmPackage rec { + frontend = mkPnpmPackage { src = ../owmods_gui/frontend; installInPlace = true; distDir = "../dist"; @@ -81,7 +98,6 @@ rustPlatform.buildRustPackage rec { downloadPage = "https://github.com/ow-mods/ow-mod-man/releases/tag/gui_v${version}"; changelog = "https://github.com/ow-mods/ow-mod-man/releases/tag/gui_v${version}"; mainProgram = "outer-wilds-mod-manager"; - sourceProvenance = with sourceTypes; [binaryNativeCode]; platforms = platforms.linux; license = licenses.gpl3; maintainers = with maintainers; [locochoco]; diff --git a/nix/shell.nix b/nix/shell.nix index 2cccd81f..b63c6513 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,26 +1,25 @@ -{nixpkgs}: let - pkgs = nixpkgs.legacyPackages."x86_64-linux"; -in - pkgs.mkShell { - name = "owmods-shell"; - buildInputs = with pkgs; [ - rustc - cargo - clippy - rustfmt - nodejs - openssl - nodePackages.pnpm - gcc - webkitgtk - glib-networking - pkg-config - libnotify - gtk3 - libsoup - typeshare - ]; - shellHook = '' - export GIO_MODULE_DIR=${pkgs.glib-networking}/lib/gio/modules/ - ''; - } +{pkgs ? import {}}: +# NOTE(Spoonbaker): This doesn't include the overlay when using `nix-shell` instead of `nix shell` +pkgs.mkShell { + name = "owmods-shell"; + buildInputs = with pkgs; [ + rustc + cargo + clippy + rustfmt + nodejs + openssl + nodePackages.pnpm + gcc + webkitgtk + glib-networking + pkg-config + libnotify + gtk3 + libsoup + typeshare + ]; + shellHook = '' + export GIO_MODULE_DIR=${pkgs.glib-networking}/lib/gio/modules/ + ''; +}