on master help sign in
build(nix): use nix-cargo-integration, make shell.nix use flake devshell
a3f0150Yusuf Bera Ertan
.envrc+4−1
@@ -1,2 +1,5 @@
1watch_file shell.nix
1watch_file shell.nix
2+watch_file flake.lock
3+
4+# try to use flakes, if it fails use normal nix (ie. shell.nix)
2−use flake
5+use flake || use nix
flake.lock+45−72
@@ -1,91 +1,83 @@
1{
1{
2 "nodes": {
2 "nodes": {
3− "flake-utils": {
3+ "devshell": {
4 "locked": {
4 "locked": {
5− "lastModified": 1620759905,
5+ "lastModified": 1622711433,
6− "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=",
6+ "narHash": "sha256-rGjXz7FA7HImAT3TtoqwecByLO5yhVPSwPdaYPBFRQw=",
7 "owner": "numtide",
7 "owner": "numtide",
8− "repo": "flake-utils",
8+ "repo": "devshell",
9− "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8",
9+ "rev": "1f4fb67b662b65fa7cfe696fc003fcc1e8f7cc36",
10 "type": "github"
10 "type": "github"
11 },
11 },
12 "original": {
12 "original": {
13 "owner": "numtide",
13 "owner": "numtide",
14− "repo": "flake-utils",
14+ "repo": "devshell",
15 "type": "github"
15 "type": "github"
16 }
16 }
17 },
17 },
18− "flake-utils_2": {
18+ "flakeCompat": {
19+ "flake": false,
19 "locked": {
20 "locked": {
20− "lastModified": 1614513358,
21+ "lastModified": 1606424373,
21− "narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
22+ "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
22− "owner": "numtide",
23+ "owner": "edolstra",
23− "repo": "flake-utils",
24+ "repo": "flake-compat",
24− "rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
25+ "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
25 "type": "github"
26 "type": "github"
26 },
27 },
27 "original": {
28 "original": {
28− "owner": "numtide",
29+ "owner": "edolstra",
29− "repo": "flake-utils",
30+ "repo": "flake-compat",
30 "type": "github"
31 "type": "github"
31 }
32 }
32 },
33 },
33 "helix": {
34 "helix": {
34 "flake": false,
35 "flake": false,
35 "locked": {
36 "locked": {
36− "lastModified": 1623200791,
37+ "lastModified": 1623545930,
37− "narHash": "sha256-kZKThNh1dBSCnISk9vwbqctk1+U0s8Lzasz/CVytJps=",
38+ "narHash": "sha256-14ASoYbxXHU/qPGctiUymb4fMRCoih9c7YujjxqEkdU=",
38 "ref": "master",
39 "ref": "master",
39− "rev": "b20e4a108cd890afa6cdf83656856fc2157a8e84",
40+ "rev": "9640ed1425f2db904fb42cd0c54dc6fbc05ca292",
40− "revCount": 789,
41+ "revCount": 821,
41 "submodules": true,
42 "submodules": true,
42 "type": "git",
43 "type": "git",
43− "url": "https://github.com/helix-editor/helix"
44+ "url": "https://github.com/helix-editor/helix.git"
44 },
45 },
45 "original": {
46 "original": {
46 "submodules": true,
47 "submodules": true,
47 "type": "git",
48 "type": "git",
48− "url": "https://github.com/helix-editor/helix"
49+ "url": "https://github.com/helix-editor/helix.git"
49 }
50 }
50 },
51 },
51− "naersk": {
52+ "nixCargoIntegration": {
52 "inputs": {
53 "inputs": {
54+ "devshell": "devshell",
53− "nixpkgs": "nixpkgs"
55+ "nixpkgs": [
56+ "nixpkgs"
57+ ],
58+ "rustOverlay": "rustOverlay"
54 },
59 },
55 "locked": {
60 "locked": {
56− "lastModified": 1620316130,
61+ "lastModified": 1623560601,
57− "narHash": "sha256-sU0VS5oJS1FsHsZsLELAXc7G2eIelVuucRw+q5B1x9k=",
62+ "narHash": "sha256-H1Dq461b2m8v/FxmPphd8pOAx4pPja0UE/xvcMUYwwY=",
58− "owner": "nmattia",
63+ "owner": "yusdacra",
59− "repo": "naersk",
64+ "repo": "nix-cargo-integration",
60− "rev": "a3f40fe42cc6d267ff7518fa3199e99ff1444ac4",
65+ "rev": "1238fd751e5d6eb030aee244da9fee6c3ad8b316",
61 "type": "github"
66 "type": "github"
62 },
67 },
63 "original": {
68 "original": {
64− "owner": "nmattia",
69+ "owner": "yusdacra",
65− "repo": "naersk",
70+ "repo": "nix-cargo-integration",
66 "type": "github"
71 "type": "github"
67 }
72 }
68 },
73 },
69 "nixpkgs": {
74 "nixpkgs": {
70 "locked": {
75 "locked": {
71− "lastModified": 1622059058,
76+ "lastModified": 1623324058,
72− "narHash": "sha256-t1/ZMtyxClVSfcV4Pt5C1YpkeJ/UwFF3oitLD7Ch/UA=",
77+ "narHash": "sha256-Jm9GUTXdjXz56gWDKy++EpFfjrBaxqXlLvTLfgEi8lo=",
73− "path": "/nix/store/2gam4i1fa1v19k3n5rc9vgvqac1c2xj5-source",
74− "rev": "84aa23742f6c72501f9cc209f29c438766f5352d",
75− "type": "path"
76− },
77− "original": {
78− "id": "nixpkgs",
79− "type": "indirect"
80− }
81− },
82− "nixpkgs_2": {
83− "locked": {
84− "lastModified": 1622194753,
85− "narHash": "sha256-76qtvFp/vFEz46lz5iZMJ0mnsWQYmuGYlb0fHgKqqMg=",
86 "owner": "nixos",
78 "owner": "nixos",
87 "repo": "nixpkgs",
79 "repo": "nixpkgs",
88− "rev": "540dccb2aeaffa9dc69bfdc41c55abd7ccc6baa3",
80+ "rev": "432fc2d9a67f92e05438dff5fdc2b39d33f77997",
89 "type": "github"
81 "type": "github"
90 },
82 },
91 "original": {
83 "original": {
@@ -95,41 +87,22 @@
95 "type": "github"
87 "type": "github"
96 }
88 }
97 },
89 },
98− "nixpkgs_3": {
99− "locked": {
100− "lastModified": 1617325113,
101− "narHash": "sha256-GksR0nvGxfZ79T91UUtWjjccxazv6Yh/MvEJ82v1Xmw=",
102− "owner": "nixos",
103− "repo": "nixpkgs",
104− "rev": "54c1e44240d8a527a8f4892608c4bce5440c3ecb",
105− "type": "github"
106− },
107− "original": {
108− "owner": "NixOS",
109− "repo": "nixpkgs",
110− "type": "github"
111− }
112− },
113 "root": {
90 "root": {
114 "inputs": {
91 "inputs": {
115− "flake-utils": "flake-utils",
92+ "flakeCompat": "flakeCompat",
116 "helix": "helix",
93 "helix": "helix",
117− "naersk": "naersk",
94+ "nixCargoIntegration": "nixCargoIntegration",
118− "nixpkgs": "nixpkgs_2",
95+ "nixpkgs": "nixpkgs"
119− "rust-overlay": "rust-overlay"
120 }
96 }
121 },
97 },
122− "rust-overlay": {
98+ "rustOverlay": {
123− "inputs": {
99+ "flake": false,
124− "flake-utils": "flake-utils_2",
125− "nixpkgs": "nixpkgs_3"
126− },
127 "locked": {
100 "locked": {
128− "lastModified": 1622257069,
101+ "lastModified": 1623550815,
129− "narHash": "sha256-+QVnS/es9JCRZXphoHL0fOIUhpGqB4/wreBsXWArVck=",
102+ "narHash": "sha256-RumRrkE6OTJDndHV4qZNZv8kUGnzwRHZQSyzx29r6/g=",
130 "owner": "oxalica",
103 "owner": "oxalica",
131 "repo": "rust-overlay",
104 "repo": "rust-overlay",
132− "rev": "8aa5f93c0b665e5357af19c5631a3450bff4aba5",
105+ "rev": "9824f142cbd7bc3e2a92eefbb79addfff8704cd3",
133 "type": "github"
106 "type": "github"
134 },
107 },
135 "original": {
108 "original": {
flake.nix+41−41
@@ -3,54 +3,54 @@
3
3
4 inputs = {
4 inputs = {
5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6− flake-utils.url = "github:numtide/flake-utils";
6+ nixCargoIntegration = {
7− rust-overlay.url = "github:oxalica/rust-overlay";
7+ url = "github:yusdacra/nix-cargo-integration";
8− naersk.url = "github:nmattia/naersk";
8+ inputs.nixpkgs.follows = "nixpkgs";
9− helix = {
9+ };
10+ flakeCompat = {
11+ url = "github:edolstra/flake-compat";
10 flake = false;
12 flake = false;
13+ };
14+ helix = {
11− url = "https://github.com/helix-editor/helix";
15+ url = "https://github.com/helix-editor/helix.git";
12 type = "git";
16 type = "git";
17+ flake = false;
13 submodules = true;
18 submodules = true;
14 };
19 };
15 };
20 };
16
21
17− outputs = inputs@{ self, nixpkgs, naersk, rust-overlay, flake-utils, ... }:
22+ outputs = inputs@{ nixCargoIntegration, helix, ... }:
18− let
23+ nixCargoIntegration.lib.makeOutputs {
19− rust = pkgs:
24+ root = ./.;
20− (pkgs.rustChannelOf {
25+ buildPlatform = "crate2nix";
21− date = "2021-05-01";
26+ renameOutputs = { "helix-term" = "helix"; };
22− channel = "nightly";
27+ # Set default app to hx (binary is from helix-term release build)
23− }).minimal; # cargo, rustc and rust-std
28+ # Set default package to helix-term release build
24−
29+ defaultOutputs = { app = "hx"; package = "helix"; };
25− mkNaerskLib = system: pkgs:
30+ overrides = {
26− naersk.lib."${system}".override {
31+ crateOverrides = common: _: {
27− # naersk can't build with stable?!
32+ helix-term = prev: { buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ]; };
28− # inherit (pkgs.rust-bin.stable.latest) rustc cargo;
33+ # link runtime since helix-core expects it because of embed_runtime feature
29− rustc = rust pkgs;
34+ helix-core = _: { preConfigure = "ln -s ${common.root + "/runtime"} ../runtime"; };
30− cargo = rust pkgs;
35+ # link languages and theme toml files since helix-view expects them
36+ helix-view = _: { preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml} .."; };
37+ helix-syntax = prev: {
38+ src = common.pkgs.runCommand prev.src.name { } ''
39+ mkdir -p $out
40+ ln -s ${prev.src}/* $out
41+ ln -sf ${helix}/helix-syntax/languages $out
42+ '';
43+ };
31 };
44 };
32−
45+ shell = common: prev: {
33− pkg = naerskLib:
46+ packages = prev.packages ++ (with common.pkgs; [ lld_10 lldb ]);
34− naerskLib.buildPackage {
47+ env = prev.env ++ [
35− pname = "helix";
48+ { name = "HELIX_RUNTIME"; eval = "$PWD/runtime"; }
36− root = inputs.helix;
49+ { name = "RUST_BACKTRACE"; value = "1"; }
37− cargoBuildOptions = self: self ++ [ ''--features "embed_runtime"'' ];
50+ { name = "RUSTFLAGS"; value = "-C link-arg=-fuse-ld=lld -C target-cpu=native"; }
51+ ];
38 };
52 };
39−
53+ build = _: prev: { rootFeatures = prev.rootFeatures ++ [ "embed_runtime" ]; };
40− in flake-utils.lib.eachDefaultSystem (system:
41− let
42− pkgs = import nixpkgs {
43− inherit system;
44− overlays = [ rust-overlay.overlay ];
45− };
46− naerskLib = mkNaerskLib system pkgs;
47− in rec {
48− packages.helix = pkg naerskLib;
49− defaultPackage = packages.helix;
50− devShell = pkgs.callPackage ./shell.nix { };
51− }) // {
52− overlay = final: prev:
53− let naerskLib = mkNaerskLib prev.system final;
54− in (rust-overlay.overlay final prev) // { helix = pkg naerskLib; };
55 };
54 };
55+ };
56}
56}
helix-term/Cargo.toml+3−1
@@ -6,7 +6,9 @@ authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
6edition = "2018"
6edition = "2018"
7license = "MPL-2.0"
7license = "MPL-2.0"
8
8
9−# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+[package.metadata.nix]
10+build = true
11+app = true
10
12
11[features]
13[features]
12embed_runtime = ["helix-core/embed_runtime"]
14embed_runtime = ["helix-core/embed_runtime"]
shell.nix+6−22
@@ -1,22 +1,6 @@
1−{ lib, stdenv, pkgs }:
1+# Flake's devShell for non-flake-enabled nix instances
2−
2+let
3−pkgs.mkShell {
3+ src = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flakeCompat.locked;
4− nativeBuildInputs = with pkgs; [
4+ compat = fetchTarball { url = "https://github.com/edolstra/flake-compat/archive/${src.rev}.tar.gz"; sha256 = src.narHash; };
5− (rust-bin.stable.latest.default.override { extensions = ["rust-src"]; })
5+in
6− lld_10
6+(import compat { src = ./.; }).shellNix.default
7− lldb
8− # pythonPackages.six
9− stdenv.cc.cc.lib
10− # pkg-config
11− ];
12− RUSTFLAGS = "-C link-arg=-fuse-ld=lld -C target-cpu=native";
13− RUST_BACKTRACE = "1";
14− # https://github.com/rust-lang/rust/issues/55979
15− LD_LIBRARY_PATH = lib.makeLibraryPath (with pkgs; [
16− stdenv.cc.cc.lib
17− ]);
18−
19− shellHook = ''
20− export HELIX_RUNTIME=$PWD/runtime
21− '';
22−}