{ description = "sounds"; inputs = { nixpkgs.url = "flake:nixpkgs"; git-hooks.url = "github:cachix/git-hooks.nix"; git-hooks.inputs.nixpkgs.follows = "nixpkgs"; proteaaudio = { url = "github:csabahruska/proteaaudio"; flake = false; }; }; outputs = inputs: let pkg = "sounds"; lib = inputs.nixpkgs.lib; fileInputs = with lib.fileset; toSource { root = ./.; fileset = unions [ ./sounds.cabal ./CHANGELOG.md #./Readme.md ./LICENSE (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./exe) ]; }; perSystem = f: lib.genAttrs lib.systems.flakeExposed (system: f rec { inherit system; pkgs = inputs.nixpkgs.legacyPackages.${system}; haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib.compose; finalHaskellPkgs: previousHaskellPkgs: { ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { }); lambdasound = (doJailbreak (unmarkBroken previousHaskellPkgs.lambdasound)).overrideAttrs (previousAttrs: { # ExplanationNote: one of lambdasound's test tries to write in `$HOME` # which defaults to the non-existent directory `/homeless-shelter`. HOME = "/tmp"; }); plots = doJailbreak (unmarkBroken previousHaskellPkgs.plots); proteaaudio = lib.pipe (finalHaskellPkgs.callCabal2nix "proteaaudio" "${inputs.proteaaudio}/proteaaudio" { libpulse = pkgs.libpulseaudio; libpulse-simple = pkgs.libpulseaudio.dev; }) [ (overrideCabal (previousDrv: { # ExplanationNote: because # `proteaaudio/proteaaudio/Sound/ProteaAudio.chs` # symlinks to `../../chs/Binding.chs` # the sibling directory ${inputs.proteaaudio}/cbits # must be available too. src = inputs.proteaaudio; postUnpack = "sourceRoot=$sourceRoot/proteaaudio"; })) ]; }); }); in rec { # nix -L build packages = perSystem ({ haskellPackages, ... }: { default = haskellPackages.${pkg}; }); # nix -L develop or direnv allow devShells = perSystem ({ pkgs, haskellPackages, system, ... }: { default = haskellPackages.shellFor { packages = ps: [ ps.${pkg} ]; nativeBuildInputs = [ haskellPackages.cabal-install haskellPackages.cabal2nix haskellPackages.haskell-language-server haskellPackages.hlint pkgs.ghciwatch pkgs.git-cliff pkgs.reuse ]; #withHoogle = true; inherit (checks.${system}.git-hooks-check) shellHook; }; }); # nix flake check checks = perSystem (args: with args; { git-hooks-check = inputs.git-hooks.lib.${system}.run { src = ./.; hooks = { cabal-fmt.enable = true; fourmolu.enable = true; hlint.enable = true; nixpkgs-fmt.enable = true; ormolu.settings.cabalDefaultExtensions = true; /* reuse = { enable = true; entry = "${pkgs.reuse}/bin/reuse lint"; pass_filenames = false; }; */ }; }; }); }; }