Skip to content

Commit e849614

Browse files
committed
nix: non-flake shell, move to crane
1 parent 41824c0 commit e849614

File tree

7 files changed

+107
-73
lines changed

7 files changed

+107
-73
lines changed

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
use flake
1+
use nix

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ jobs:
1010
- uses: cachix/install-nix-action@v31
1111
with:
1212
nix_path: nixpkgs=channel:nixos-unstable
13-
- run: nix build -v -L
13+
- run: nix build -v -L .#entrace
14+
- run: nix build -v -L .#entrace_core
15+
- run: nix build -v -L .#entrace_core_lite

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*.et
55
*.iet
66
**/**.et
7-
.direnv
7+
.direnv
8+
result

flake.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
inputs = {
55
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
66
fenix.url = "github:nix-community/fenix/monthly";
7+
crane.url = "github:ipetkov/crane";
78
};
89

910
outputs =
1011
{
1112
self,
1213
nixpkgs,
1314
fenix,
15+
crane,
1416
}:
1517
let
1618
systems = nixpkgs.lib.systems.flakeExposed;
@@ -20,34 +22,65 @@
2022
system:
2123
let
2224
pkgs = nixpkgs.legacyPackages.${system};
23-
rustfmt_nightly = fenix.packages.${system}.default.rustfmt;
25+
rustfmt-nightly = fenix.packages.${system}.default.rustfmt;
26+
craneLib = crane.mkLib pkgs;
27+
rpath-libs = [
28+
pkgs.libGL
29+
pkgs.libxkbcommon
30+
pkgs.wayland
31+
pkgs.luajit
32+
];
33+
craneCommonArgs = {
34+
pname = "entrace";
35+
version = "0.1.1";
36+
src = pkgs.lib.fileset.toSource {
37+
root = ./.;
38+
fileset = pkgs.lib.fileset.unions [
39+
(craneLib.fileset.commonCargoSources ./.)
40+
(pkgs.lib.fileset.fileFilter (file: file.hasExt "md") ./.)
41+
(pkgs.lib.fileset.maybeMissing ./gui/vendor)
42+
(pkgs.lib.fileset.maybeMissing ./docs)
43+
];
44+
};
45+
buildInputs = [ ] ++ rpath-libs;
46+
nativeBuildInputs = [
47+
pkgs.breakpointHook
48+
pkgs.mold-wrapped
49+
pkgs.patchelf
50+
pkgs.pkg-config
51+
];
52+
};
53+
cargoArtifacts = craneLib.buildDepsOnly craneCommonArgs;
54+
craneWithCommonArgs =
55+
x: craneLib.buildPackage (craneCommonArgs // { inherit cargoArtifacts; } // x);
56+
entraceApp = craneWithCommonArgs {
57+
pname = "entrace";
58+
cargoExtraArgs = "-p entrace";
59+
postFixup = ''
60+
ENTRACE_BIN="$out/bin/entrace"
61+
patchelf --add-rpath ${pkgs.lib.makeLibraryPath rpath-libs} "$ENTRACE_BIN"
62+
patchelf \
63+
--add-needed libwayland-client.so \
64+
--add-needed libxkbcommon.so \
65+
--add-needed libEGL.so \
66+
--add-needed libluajit-5.1.so "$ENTRACE_BIN"
67+
'';
68+
};
2469
in
2570
{
26-
devShells.${system}.default =
27-
let
28-
libPathPackages = [
29-
pkgs.wayland
30-
pkgs.libxkbcommon
31-
pkgs.libGL
32-
];
33-
_libPathPackagesStr = builtins.toString (pkgs.lib.makeLibraryPath libPathPackages);
34-
in
35-
pkgs.mkShell {
36-
packages = libPathPackages ++ [
37-
pkgs.sqlite
38-
pkgs.mold-wrapped
39-
pkgs.pkg-config
40-
pkgs.luajit
41-
pkgs.zenity
42-
rustfmt_nightly
43-
pkgs.cargo-about
44-
];
45-
env.RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
46-
shellHook = ''
47-
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${_libPathPackagesStr}"
48-
'';
71+
devShells.${system}.default = import ./shell.nix { inherit pkgs rustfmt-nightly; };
72+
packages.${system} = {
73+
default = entraceApp;
74+
entrace = entraceApp;
75+
entrace_core = craneWithCommonArgs {
76+
pname = "entrace_core";
77+
cargoExtraArgs = "-p entrace_core";
78+
};
79+
entrace_core_lite = craneCommonArgs {
80+
pname = "entrace_core_lite";
81+
cargoExtraArgs = "-p entrace_core --no-default-features";
4982
};
50-
packages.${system}.default = pkgs.callPackage ./package.nix { };
83+
};
5184
}
5285
);
5386
}

package.nix

Lines changed: 0 additions & 45 deletions
This file was deleted.

shell.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
pkgs ? import <nixpkgs> { },
3+
rustfmt-nightly ? pkgs.rustfmt,
4+
}:
5+
6+
let
7+
libPathPackages = [
8+
pkgs.wayland
9+
pkgs.libxkbcommon
10+
pkgs.libGL
11+
];
12+
in
13+
pkgs.mkShell {
14+
packages = libPathPackages ++ [
15+
pkgs.sqlite
16+
pkgs.mold-wrapped
17+
pkgs.pkg-config
18+
pkgs.luajit
19+
pkgs.zenity
20+
rustfmt-nightly
21+
pkgs.cargo-about
22+
];
23+
env.RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
24+
shellHook = ''
25+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath libPathPackages}"
26+
'';
27+
}

0 commit comments

Comments
 (0)