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";
10 literate-phylomemy.inputs.nixpkgs.follows = "nixpkgs";
11 # When working on a local clone:
12 #literate-phylomemy.url = "git+file:///home/julm/work/sourcephile/haskell/literate-phylomemy";
13 logic.url = "git+https://radicle-mermet.sourcephile.fr/z3795BqJN8hSMGkyAUr8hHviEEi2H.git";
14 logic.inputs.nixpkgs.follows = "nixpkgs";
19 lib = inputs.nixpkgs.lib;
20 # Helper to build for each system in `lib.systems.flakeExposed`.
23 lib.genAttrs lib.systems.flakeExposed (
27 pkgs = import inputs.nixpkgs { inherit system; };
28 haskellPackages = pkgs.haskellPackages;
34 packages = perSystem (
35 { pkgs, system, haskellPackages, ... }:
37 # The Glasgow Haskell Compiler (GHC)
38 # Here made available as `.#ghc` for script.hs's shebang
39 ghc = haskellPackages.ghcWithPackages (
41 # Extra Haskell packages available
42 inputs.literate-phylomemy.packages.${system}.default
43 inputs.logic.packages.${system}.default
44 haskellPackages.bytestring
45 haskellPackages.turtle
46 haskellPackages.pretty-show
51 # A compiled version of `script.hs`
52 # (instead of an interpreted one when run as `./script.hs`)
53 # To avoid writing a `.cabal` file, `ghc --make` is called directly here,
54 # but should the script become a full fledge executable,
55 # a `.cabal` file should be written instead.
56 default = pkgs.stdenv.mkDerivation {
60 inputs.self.packages.${system}.ghc
64 ghc -o "$out/bin/script" -O2 --make ./script.hs
69 # `nix develop` or `direnv allow`
70 devShells = perSystem (
71 { pkgs, system, ... }:
73 default = pkgs.mkShell {
75 inputs.self.packages.${system}.ghc
76 pkgs.haskellPackages.haskell-language-server
77 pkgs.haskellPackages.hlint