-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
141 lines (138 loc) · 4.41 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.21)
{
# A helpful description of your flake
description = "content agnostic spaced repetition";
# Flake inputs
inputs = {
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# Flake outputs that other flakes can use
outputs =
{
self,
flake-schemas,
nixpkgs,
rust-overlay,
flake-parts,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs self; } {
imports = [
inputs.flake-root.flakeModule
inputs.flake-parts.flakeModules.easyOverlay
];
flake = {
# Schemas tell Nix about the structure of your flake's outputs
schemas = flake-schemas.schemas;
};
systems = [
"x86_64-linux"
];
perSystem =
{
pkgs,
self',
system,
config,
...
}:
let
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
rustc = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustToolchain = final.rust-bin.selectLatestNightlyWith (
toolchain:
toolchain.default.override {
extensions = [ "rust-src" ];
}
);
})
];
config = { };
};
flake-root.projectRootFile = "flake.nix"; # Not necessary, as flake.nix is the default
devShells.default = pkgs.mkShell {
inputsFrom = [ config.flake-root.devShell ]; # Provides $FLAKE_ROOT in dev shell
packages = with pkgs; [
(python3.withPackages (python-pkgs: [
python-pkgs.click
python-pkgs.typer
python-pkgs.prompt-toolkit
]))
python312Packages.jedi-language-server
python312Packages.ruff
self'.packages.spbasedctl
bash-language-server
fzf
glow
nodejs
gum
jq
rustToolchain
cargo-bloat
cargo-edit
rust-analyzer
];
env = {
# RUST_BACKTRACE = "1";
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
};
packages =
let
script_dependencies = with pkgs; [
glow
gum
jq
];
create_script =
{ name, src }:
let
script = (pkgs.writeScriptBin name src).overrideAttrs (old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
pkgs.symlinkJoin {
inherit name;
paths = [ script ] ++ script_dependencies;
postBuild = "wrapProgram $out/bin/${name} --prefix PATH : $out/bin";
buildInputs = [ pkgs.makeWrapper ];
};
in
{
default = self'.packages.spbasedctl;
spbasedctl = rustPlatform.buildRustPackage {
inherit (cargoToml) version;
name = "spbasedctl";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = "--package spbasedctl";
};
flashcard = create_script {
name = "flashcard";
src = builtins.readFile ./scripts/flashcard;
};
reading = create_script {
name = "reading";
src = builtins.readFile ./scripts/reading;
};
};
};
};
}