diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..25ab9be --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).defaultNix \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..25965c3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1641205782, + "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1644151317, + "narHash": "sha256-TpXGBYCFKvEN7Q+To45rn4kqTbLPY4f56rF6ymUGGRE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "942b0817e898262cc6e3f0a5f706ce09d8f749f1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fc243f5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + description = "A tool for organising a music library"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, utils, ... }: + { + overlay = final: prev: + let + system = final.system; + fold-to-ascii = final.python3Packages.callPackage ./nix-extra-deps/fold-to-ascii.nix { }; + in { + fold-to-ascii = {fold-to-ascii = fold-to-ascii;}; + musicutil = { + musicutil = final.python3Packages.buildPythonApplication rec { + pname = "musicutil"; + version = "latest"; + + src = ./.; + + postPatch = '' + substituteInPlace musicutil/meta.py --replace 'ffmpeg_path = "ffmpeg"' 'ffmpeg_path = "${final.ffmpeg}/bin/ffmpeg"' + substituteInPlace musicutil/meta.py --replace 'ffprobe_path = "ffprobe"' 'ffprobe_path = "${final.ffmpeg}/bin/ffprobe"' + substituteInPlace musicutil/meta.py --replace 'r128gain_path = "r128gain"' 'r128gain_path = "${final.r128gain}/bin/r128gain"' + ''; + + doCheck = false; + + propagatedBuildInputs = with final.python3Packages; [ + mutagen + fold-to-ascii + pyyaml + ]; + }; + }; + }; + } // utils.lib.eachSystem (utils.lib.defaultSystems) (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }; + in { + defaultPackage = self.packages."${system}".musicutil; + packages.musicutil = pkgs.musicutil.musicutil; + + defaultApp = self.apps."${system}".musicutil; + apps.musicutil = { + type = "app"; + program = "${self.defaultPackage."${system}"}/bin/musicutil"; + }; + + devShell = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.musicutil ]; + buildInputs = with pkgs; + [ + nixUnstable + mutagen + self.packages.${system}.fold-to-ascii + pyyaml + ]; + }; + lib = pkgs.musicutil.lib; + }); +} diff --git a/result b/result new file mode 120000 index 0000000..cbc74c8 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/inz0v6slr3z7akjy6j7ds34rgxa08bnf-musicutil-latest \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 8e0f2a7..0000000 --- a/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs ? import { } }: -let - fold-to-ascii = (py: py.callPackage ./nix-extra-deps/fold-to-ascii.nix { }); - my_python = pkgs.python39.withPackages - (py: with py; [ (fold-to-ascii py) py.mutagen py.autopep8 py.pyyaml ]); - -in pkgs.mkShell { packages = with pkgs; [ my_python ffmpeg fd r128gain ]; }