add flake!

This commit is contained in:
ChaotiCryptidz 2022-02-08 11:25:17 +00:00
parent 9880c175a6
commit 7b34eaeb8d
5 changed files with 146 additions and 7 deletions

13
default.nix Normal file
View file

@ -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

60
flake.lock Normal file
View file

@ -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
}

72
flake.nix Normal file
View file

@ -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;
});
}

1
result Symbolic link
View file

@ -0,0 +1 @@
/nix/store/inz0v6slr3z7akjy6j7ds34rgxa08bnf-musicutil-latest

View file

@ -1,7 +0,0 @@
{ pkgs ? import <nixpkgs> { } }:
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 ]; }