1 # SPDX-FileCopyrightText: 2024 Jane Doe <jane@example.org>
2 # SPDX-License-Identifier: CC0-1.0
4 description = "A phylomemy script example";
7 # nix flake lock --override-input nixpkgs github:NixOS/nixpkgs
8 nixpkgs.url = "flake:nixpkgs";
9 literate-phylomemy.url = "git+https://seed.radicle.garden/z2364hmzZUAGy1nKdSFa1gLSoUE2M.git";
14 lib = inputs.nixpkgs.lib;
15 # Helper to build for each system in `lib.systems.flakeExposed`.
18 lib.genAttrs lib.systems.flakeExposed (
22 pkgs = import inputs.nixpkgs { inherit system; };
23 haskellPackages = pkgs.haskellPackages;
29 packages = perSystem (
30 { pkgs, system, haskellPackages, ... }:
32 # The Glasgow Haskell Compiler (GHC)
33 # Here made available as `.#ghc` for script.hs's shebang
34 ghc = haskellPackages.ghcWithPackages (
36 # Extra Haskell packages available
37 inputs.literate-phylomemy.packages.${system}.default
38 haskellPackages.bytestring
39 haskellPackages.turtle
40 haskellPackages.pretty-show
45 # A compiled version of `script.hs`
46 # (instead of an interpreted one when run as `./script.hs`)
47 # To avoid writing a `.cabal` file, `ghc --make` is called directly here,
48 # but should the script become a full fledge executable,
49 # a `.cabal` file should be written instead.
50 default = pkgs.stdenv.mkDerivation {
54 inputs.self.packages.${system}.ghc
58 ghc -o "$out/bin/script" -O2 --make ./script.hs
63 # `nix develop` or `direnv allow`
64 devShells = perSystem (
65 { pkgs, system, ... }:
67 default = pkgs.mkShell {
69 inputs.self.packages.${system}.ghc
70 pkgs.haskellPackages.haskell-language-server
71 pkgs.haskellPackages.hlint