aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 27b949e047addc68801d4a9ed399739ed51a9dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
  description = "discidurl - output the MusicBrainz submission URL for a disc";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

  outputs =
    { self, nixpkgs }:
    let
      systems = [ "x86_64-linux" ];

      forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});

      discidurl =
        {
          lib,
          stdenv,
          pkg-config,
          libdiscid,
        }:
        stdenv.mkDerivation {
          pname = "discidurl";
          version = "0-unstable-${self.shortRev or self.dirtyShortRev or "dirty"}";

          src = ./.;

          nativeBuildInputs = [ pkg-config ];
          buildInputs = [ libdiscid ];

          makeFlags = [ "PREFIX=$(out)" ];

          meta = {
            mainProgram = "discidurl";
            license = lib.licenses.lgpl21Plus;
            # TODO: test if I ever need on another platform
            platforms = lib.platforms.linux;
          };
        };
    in
    {
      packages = forAllSystems (pkgs: {
        default = pkgs.callPackage discidurl { };
      });

      overlays.default = final: prev: {
        discidurl = final.callPackage discidurl { };
      };

      devShells = forAllSystems (pkgs: {
        default = pkgs.mkShell {
          inputsFrom = [ (pkgs.callPackage discidurl { }) ];
        };
      });
    };
}