Skip to content

Commit 3636f2c

Browse files
authored
feat(nix): add cli package and devshell prompt prefix (#421)
1 parent 07fea61 commit 3636f2c

1 file changed

Lines changed: 44 additions & 25 deletions

File tree

flake.nix

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
nixConfig.bash-prompt-prefix = "(neothesia) ";
3+
24
inputs = {
35
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
46
systems.url = "github:nix-systems/default";
@@ -28,11 +30,31 @@
2830
overlays = [inputs.rust-overlay.overlays.default];
2931
};
3032
in
31-
f system pkgs);
33+
f pkgs.stdenv.hostPlatform.system pkgs);
3234

3335
meta = (inputs.nixpkgs.lib.importTOML ./neothesia/Cargo.toml).package;
36+
37+
workspace = inputs.nixpkgs.lib.cleanSourceWith {
38+
name = "${meta.name}-${meta.version}-src";
39+
src = ./.;
40+
filter = inputs.gitignore.lib.gitignoreFilterWith {
41+
basePath = ./.;
42+
extraRules =
43+
# gitignore
44+
''
45+
flake.*
46+
LICENSE.md
47+
README.md
48+
.github
49+
makefile
50+
*.sf2
51+
*.mid
52+
docs
53+
'';
54+
};
55+
};
3456
in {
35-
packages = forAllSystems (_system: pkgs: let
57+
packages = forAllSystems (system: pkgs: let
3658
rustToolchain =
3759
pkgs.rust-bin.nightly.latest.default.override
3860
{extensions = ["rust-src" "rust-analyzer"];};
@@ -43,34 +65,31 @@
4365
clippy = rustToolchain;
4466
};
4567
in {
46-
default = naersk.buildPackage {
68+
# `nix run github:PolyMeilex/Neothesia`
69+
default = inputs.self.outputs.packages.${system}.neothesia;
70+
neothesia = naersk.buildPackage {
4771
meta.mainProgram = "neothesia";
48-
src = pkgs.lib.cleanSourceWith {
49-
name = "${meta.name}-${meta.version}-src";
50-
src = ./.;
51-
filter = inputs.gitignore.lib.gitignoreFilterWith {
52-
basePath = ./.;
53-
extraRules =
54-
# gitignore
55-
''
56-
flake.*
57-
LICENSE.md
58-
README.md
59-
.github
60-
makefile
61-
*.sf2
62-
*.mid
63-
docs
64-
'';
65-
};
66-
};
72+
src = workspace;
73+
};
74+
75+
# `nix run github:PolyMeilex/Neothesia#cli`
76+
cli = naersk.buildPackage {
77+
cargoBuildOptions = prev: prev ++ ["--package" "neothesia-cli"];
78+
nativeBuildInputs = [
79+
pkgs.pkg-config
80+
pkgs.ffmpeg_8.dev
81+
];
82+
meta.mainProgram = "neothesia-cli";
83+
src = workspace;
6784
};
6885
});
6986

7087
devShells = forAllSystems (system: pkgs: {
71-
default =
72-
pkgs.mkShell
73-
{inputsFrom = [self.packages.${system}.default];};
88+
# `nix develop github:PolyMeilex/Neothesia`
89+
default = pkgs.mkShell {
90+
# grab all build dependencies of all exposed packages
91+
inputsFrom = pkgs.lib.attrValues inputs.self.packages.${system};
92+
};
7493
});
7594
};
7695
}

0 commit comments

Comments
 (0)