on master help sign in
fold/flake.nix
75 lines 2.1 kB history raw
1{
2 description = "fold — one outline of notes and tasks in plain Markdown, in the terminal";
4 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 outputs =
7 { self, nixpkgs }:
8 let
9 systems = [
10 "x86_64-linux"
11 "aarch64-linux"
12 "x86_64-darwin"
13 "aarch64-darwin"
14 ];
15 forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
17 mkFold =
18 pkgs:
19 pkgs.rustPlatform.buildRustPackage {
20 pname = "fold";
21 version = "0.1.0";
22 # only what the build reads, so editing SPEC.md does not rebuild
23 src = pkgs.lib.fileset.toSource {
24 root = ./.;
25 fileset = pkgs.lib.fileset.unions [
26 ./Cargo.toml
27 ./Cargo.lock
28 ./crates
29 ];
30 };
31 cargoLock.lockFile = ./Cargo.lock;
32 cargoBuildFlags = [ "-p" "fold-cli" ];
33 # the test suite runs in `nix flake check` (checks.default)
34 doCheck = false;
35 meta = {
36 description = "One outline of notes and tasks in plain Markdown, in the terminal";
37 mainProgram = "fold";
38 platforms = systems;
39 };
40 };
41 in
42 {
43 packages = forAll (pkgs: rec {
44 fold = mkFold pkgs;
45 default = fold;
46 });
48 # `nix flake check`: the whole workspace's tests
49 checks = forAll (pkgs: {
50 default = (mkFold pkgs).overrideAttrs (_: {
51 pname = "fold-tests";
52 doCheck = true;
53 cargoTestFlags = [ "--workspace" ];
54 # the trash lives under $XDG_STATE_HOME; the sandbox has no home
55 preCheck = ''
56 export HOME=$(mktemp -d)
57 export XDG_STATE_HOME=$HOME/.local/state
58 '';
59 });
60 });
62 devShells = forAll (pkgs: {
63 default = pkgs.mkShell {
64 inputsFrom = [ (mkFold pkgs) ];
65 packages = with pkgs; [
66 cargo
67 rustc
68 clippy
69 rustfmt
70 rust-analyzer
71 ];
72 };
73 });
74 };