From 20ef74cdac7e3432a8ebf3015c065c763e1818c6 Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Tue, 19 Aug 2025 08:41:49 +1000 Subject: [PATCH] nix: make usage in non-flake setups easier (#296) * nix: extract overlay into own file * readme: document non-flake nixos usage --- README.md | 29 ++++++++++++++++++++++++++++- contrib/package/nix/overlay.nix | 11 +++++++++++ flake.nix | 11 +---------- 3 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 contrib/package/nix/overlay.nix diff --git a/README.md b/README.md index 1d143b6d..4754feb4 100644 --- a/README.md +++ b/README.md @@ -2344,7 +2344,7 @@ some recommended dependencies are enabled by default; [override the package](htt ## nixos module -for this setup, you will need a [flake-enabled](https://nixos.wiki/wiki/Flakes) installation of NixOS. +for [flake-enabled](https://nixos.wiki/wiki/Flakes) installations of NixOS: ```nix { @@ -2371,6 +2371,33 @@ for this setup, you will need a [flake-enabled](https://nixos.wiki/wiki/Flakes) } ``` +if you don't use a flake in your configuration, you can use other dependency management tools like [npins](https://github.com/andir/npins), [niv](https://github.com/nmattia/niv), or even plain [`fetchTarball`](https://nix.dev/manual/nix/stable/language/builtins#builtins-fetchTarball), like so: + +```nix +{ pkgs, ... }: + +let + # npins example, adjust for your setup. copyparty should be a path to the downloaded repo + # for niv, just replace the npins folder import with the sources.nix file + copyparty = (import ./npins).copyparty; + + # or with fetchTarball: + copyparty = fetchTarball "https://github.com/9001/copyparty/archive/hovudstraum.tar.gz"; +in + +{ + # load the copyparty NixOS module + imports = [ "${copyparty}/contrib/nixos/modules/copyparty.nix" ]; + + # add the copyparty overlay to expose the package to the module + nixpkgs.overlays = [ "${copyparty}/contrib/package/nix/overlay.nix" ]; + # (optional) install the package globally + environment.systemPackages = [ pkgs.copyparty ]; + # configure the copyparty module + services.copyparty.enable = true; +} +``` + copyparty on NixOS is configured via `services.copyparty` options, for example: ```nix services.copyparty = { diff --git a/contrib/package/nix/overlay.nix b/contrib/package/nix/overlay.nix new file mode 100644 index 00000000..ca8d5c6e --- /dev/null +++ b/contrib/package/nix/overlay.nix @@ -0,0 +1,11 @@ +final: prev: { + copyparty = final.python3.pkgs.callPackage ./copyparty { + ffmpeg = final.ffmpeg-full; + }; + + python3 = prev.python3.override { + packageOverrides = pyFinal: pyPrev: { + partftpy = pyFinal.callPackage ./partftpy { }; + }; + }; +} diff --git a/flake.nix b/flake.nix index c5181bfe..336642ee 100644 --- a/flake.nix +++ b/flake.nix @@ -12,16 +12,7 @@ }: { nixosModules.default = ./contrib/nixos/modules/copyparty.nix; - overlays.default = final: prev: { - copyparty = final.python3.pkgs.callPackage ./contrib/package/nix/copyparty { - ffmpeg = final.ffmpeg-full; - }; - python3 = prev.python3.override { - packageOverrides = pyFinal: pyPrev: { - partftpy = pyFinal.callPackage ./contrib/package/nix/partftpy { }; - }; - }; - }; + overlays.default = import ./contrib/package/nix/overlay.nix; } // flake-utils.lib.eachDefaultSystem ( system: