on master help sign in
add flake.nix: nix run/build the fold binary, nix flake check runs the tests, dev shell
commit970373bf632170dd2a85d5d98c39dab6643c51b8 authoriko <ilyakooo0@gmail.com> dateSat 26 Sep 2026, 06:08 (1 month ago) parent786c670
3 files changed+104
.gitignore+2 flake.lock+27 flake.nix+75
.gitignore+2
@@ -1,2 +1,4 @@
11target/
22.vix/
3+result
4+result-*
flake.locknew file+27
@@ -0,0 +1,27 @@
1+{
2+ "nodes": {
3+ "nixpkgs": {
4+ "locked": {
5+ "lastModified": 1790323409,
6+ "narHash": "sha256-VVTPf+Hyd5ebpjBMHmrLMSBIeW6ls48Bqtosj7CNKLA=",
7+ "owner": "NixOS",
8+ "repo": "nixpkgs",
9+ "rev": "e94cb152ed51bd6e24eb4a41f1460252beb52cd2",
10+ "type": "github"
11+ },
12+ "original": {
13+ "owner": "NixOS",
14+ "ref": "nixos-unstable",
15+ "repo": "nixpkgs",
16+ "type": "github"
17+ }
18+ },
19+ "root": {
20+ "inputs": {
21+ "nixpkgs": "nixpkgs"
22+ }
23+ }
24+ },
25+ "root": "root",
26+ "version": 7
27+}
flake.nixnew file+75
@@ -0,0 +1,75 @@
1+{
2+ description = "fold — one outline of notes and tasks in plain Markdown, in the terminal";
3+
4+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5+
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});
16+
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+ });
47+
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+ });
61+
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+ };
75+}