From 9493a79e88879eb3a4670c693692b5cf2cf63e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Mon, 27 Jul 2026 21:04:54 +0200 Subject: [PATCH] add nix flake for dev env --- .gitignore | 1 + flake.lock | 356 +++++++++++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 76 ++++++++++++ 3 files changed, 426 insertions(+), 7 deletions(-) create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index d43593b2..05979f9e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .idea/ *.iml *.kdev4 +.devenv/ #Generated binary translation files *.mo \ No newline at end of file diff --git a/flake.lock b/flake.lock index fae3d582..146edff2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,366 @@ { "nodes": { + "cachix": { + "inputs": { + "devenv": [ + "devenv" + ], + "flake-compat": [ + "devenv", + "flake-compat" + ], + "git-hooks": [ + "devenv", + "git-hooks" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1777487137, + "narHash": "sha256-TuvKVBX60mqyMT6OB5JqVEh1YIWtFMR/igLCaCdC9tw=", + "owner": "cachix", + "repo": "cachix", + "rev": "a66a440c321d35f7193472c317f42a55ccd1cb93", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "latest", + "repo": "cachix", + "type": "github" + } + }, + "crate2nix": { + "flake": false, + "locked": { + "lastModified": 1772186516, + "narHash": "sha256-8s28pzmQ6TOIUzznwFibtW1CMieMUl1rYJIxoQYor58=", + "owner": "rossng", + "repo": "crate2nix", + "rev": "ba5dd398e31ee422fbe021767eb83b0650303a6e", + "type": "github" + }, + "original": { + "owner": "rossng", + "repo": "crate2nix", + "rev": "ba5dd398e31ee422fbe021767eb83b0650303a6e", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "crate2nix": "crate2nix", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "ghostty": "ghostty", + "git-hooks": "git-hooks", + "nix": "nix", + "nixd": "nixd", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1785127153, + "narHash": "sha256-vX6OVIUWiEiD5v1InHQk1OTjJsK2WgEqWmMPeIS5l78=", + "owner": "cachix", + "repo": "devenv", + "rev": "6319d63344675f65c2c213be95084544866d8951", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "ghostty": { + "flake": false, + "locked": { + "lastModified": 1784602798, + "narHash": "sha256-298x90knBUWX5GHGXh2SKsAKvStjU2ri9UgOGoF79/8=", + "owner": "ghostty-org", + "repo": "ghostty", + "rev": "88b4cd047fa627cdca6781bc7e7dc8b75a2cecb9", + "type": "github" + }, + "original": { + "owner": "ghostty-org", + "repo": "ghostty", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1782908218, + "narHash": "sha256-wLMOrPgVyeF3XmP+qfYcLqnVdTxikdcSvbIY7rA9jTA=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "9f7e99119ece7705299595299f3b031f39356de1", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-parts": [ + "devenv", + "flake-parts" + ], + "git-hooks-nix": [ + "devenv", + "git-hooks" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-23-11": [ + "devenv" + ], + "nixpkgs-regression": [ + "devenv" + ] + }, + "locked": { + "lastModified": 1782407171, + "narHash": "sha256-xem+4ncdQCTFJsQ4PrVuyVmi3j4w/Yqg298hBUzVejA=", + "owner": "cachix", + "repo": "nix", + "rev": "782ac1b155679b065ec945ae50d0fa1d495883b7", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "devenv-2.34", + "repo": "nix", + "type": "github" + } + }, + "nixd": { + "inputs": { + "flake-parts": [ + "devenv", + "flake-parts" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1783935112, + "narHash": "sha256-IAQ14nteIKXAz4cd75UcZrsHGEVJ7QNrkUwX9rmeZ/Y=", + "owner": "nix-community", + "repo": "nixd", + "rev": "a64cd33e53b316b6b092ea0a966640cd2309bf3d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixd", + "type": "github" + } + }, "nixpkgs": { + "inputs": { + "nixpkgs-src": "nixpkgs-src" + }, + "locked": { + "lastModified": 1782132010, + "narHash": "sha256-ZnAVHdVrotp80iIMm5CSR1fdxPlw7Uwmwxb+O/wsgZ8=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "12866ae2dddbc0ab8b329915f8072bb9c75bde89", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-src": { + "flake": false, + "locked": { + "lastModified": 1781607440, + "narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3e41b24abd260e8f71dbe2f5737d24122f972158", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-src_2": { + "flake": false, "locked": { - "lastModified": 1763678758, - "narHash": "sha256-+hBiJ+kG5IoffUOdlANKFflTT5nO3FrrR2CA3178Y5s=", - "owner": "nixos", + "lastModified": 1784783405, + "narHash": "sha256-4IHyyLgLBdKefkljdKod4IMn023pQiDXAWJA187cmdY=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "117cc7f94e8072499b0a7aa4c52084fa4e11cc9b", + "rev": "7525d999cd850b9a488817abc89c75dc733acf17", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs_2": { + "inputs": { + "nixpkgs-src": "nixpkgs-src_2" + }, + "locked": { + "lastModified": 1785104946, + "narHash": "sha256-VLSslwCjlsICjyaUfrS7lGMypmO03fzmDAqhD85Ae84=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "c946ff36bf193309589932c371bd5ae6653c912e", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "devenv": "devenv", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay_2" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1782875958, + "narHash": "sha256-5eqDcnBjb1424HRQdnhuhNOBZguq1Z2tqSa2OMF/m2c=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "13139aefa973f3d96c60c0fbab801de058ae25ca", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1785131767, + "narHash": "sha256-VNbQv2P0zgaNh96mT4LrnX7hdXgiC5nBH+uvyrrVX7U=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c67ce00525464a710971351c183ce67acb6ca827", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "devenv", + "nixd", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1780220602, + "narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "db947814a175b7ca6ded66e21383d938df01c227", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..93d4082a --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + inputs = { + nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; + devenv.url = "github:cachix/devenv"; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs = { nixpkgs.follows = "nixpkgs"; }; + }; + + nixConfig = { + extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; + extra-substituters = "https://devenv.cachix.org"; + }; + + outputs = { self, nixpkgs, devenv, ... } @ inputs: + let + system = "aarch64-darwin"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages.${system}.devenv-up = self.devShells.${system}.default.config.procfileScript; + #packages.${system}.devenv-test = self.devShells.${system}.default.config.test; + + devShells.${system}.default = devenv.lib.mkShell { + inherit inputs pkgs; + modules = [ + ({ pkgs, config, ... }: { + # This is your devenv configuration + + languages.rust = { + enable = true; + # https://devenv.sh/reference/options/#languagesrustchannel + channel = "stable"; + + components = [ "rustc" "cargo" "clippy" "rustfmt" "rust-analyzer" ]; /* "miri" doesn't work on stable */ + }; + + packages = [ + # Native build tools + pkgs.pkg-config # locate the C libraries below + pkgs.cmake # libgit2-sys vendored build + pkgs.capnproto # `capnp` for sequoia-ipc build.rs + pkgs.gettext # `msgfmt` for cursive translation files + pkgs.llvmPackages.libclang # bindgen (gpgme-sys / nettle-sys) + + # C libraries every crate links against + pkgs.openssl # git2 / reqwest (native-tls) + pkgs.libgit2 # git operations + pkgs.gpgme # gpgme encryption backend + pkgs.libgpg-error # gpgme encryption backend + pkgs.nettle # sequoia encryption backend + pkgs.glib # gtk / gio + + # GTK front-end (ripasso-gtk) + pkgs.gtk4 + pkgs.libadwaita + + # Runtime tool used by the gpgme test-suite + pkgs.gnupg + ]; + + env = { + EDITOR = "emacs -nw "; + # Link against the nixpkgs OpenSSL instead of vendoring it. + OPENSSL_NO_VENDOR = "1"; + # bindgen (gpgme-sys, nettle-sys) needs to find libclang. + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + }; + + # Convenience commands: `build-all` and `test-all`. + scripts.build-all.exec = "cargo build --all"; + scripts.test-all.exec = "cargo test --all"; + }) + ]; + }; + }; +}