# SPDX-FileCopyrightText: 2024 Jane Doe # SPDX-License-Identifier: CC0-1.0 { description = "A phylomemy script example"; inputs = { # Update with: # nix flake lock --override-input nixpkgs github:NixOS/nixpkgs nixpkgs.url = "flake:nixpkgs"; literate-phylomemy.url = "git+https://seed.radicle.garden/z2364hmzZUAGy1nKdSFa1gLSoUE2M.git"; }; outputs = inputs: let lib = inputs.nixpkgs.lib; # Helper to build for each system in `lib.systems.flakeExposed`. perSystem = f: lib.genAttrs lib.systems.flakeExposed ( system: f rec { inherit system; pkgs = import inputs.nixpkgs { inherit system; }; haskellPackages = pkgs.haskellPackages; } ); in { # `nix -L build` packages = perSystem ( { pkgs, system, haskellPackages, ... }: { # The Glasgow Haskell Compiler (GHC) # Here made available as `.#ghc` for script.hs's shebang ghc = haskellPackages.ghcWithPackages ( haskellPackages: [ # Extra Haskell packages available inputs.literate-phylomemy.packages.${system}.default haskellPackages.bytestring haskellPackages.turtle haskellPackages.pretty-show ] ); ghcid = pkgs.ghcid; xdot = pkgs.xdot; # A compiled version of `script.hs` # (instead of an interpreted one when run as `./script.hs`) # To avoid writing a `.cabal` file, `ghc --make` is called directly here, # but should the script become a full fledge executable, # a `.cabal` file should be written instead. default = pkgs.stdenv.mkDerivation { name = "script"; src = ./.; buildInputs = [ inputs.self.packages.${system}.ghc ]; buildPhase = '' mkdir -p $out/bin ghc -o "$out/bin/script" -O2 --make ./script.hs ''; }; } ); # `nix develop` or `direnv allow` devShells = perSystem ( { pkgs, system, ... }: { default = pkgs.mkShell { nativeBuildInputs = [ inputs.self.packages.${system}.ghc pkgs.haskellPackages.haskell-language-server pkgs.haskellPackages.hlint pkgs.reuse pkgs.xdot ]; }; } ); }; }