Reorganized

This commit is contained in:
Jan-Bulthuis committed 2025-05-09 15:27:44 +02:00
1 parent c3c61ce654
commit 760815da50
145 files changed
-1444

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
{
nixpkgs,
flake-utils,
...
}:
let
imports = [
./shell.nix
./languages/python.nix
./languages/rust.nix
./utilities/cuda.nix
./utilities/jupyter.nix
];
in
{
mkShell =
attrs:
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
evaluated =
(nixpkgs.lib.evalModules {
modules = [ attrs ] ++ imports;
specialArgs = {
pkgs = pkgs;
};
}).config;
recUpdate = nixpkgs.lib.recursiveUpdate;
libPackages = evaluated.libPackages pkgs;
shell = recUpdate {
env =
evaluated.env
// (
if (libPackages != [ ]) then
{
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath libPackages;
}
else
{ }
);
packages = evaluated.packages ++ (evaluated.extraPackages pkgs) ++ libPackages;
} evaluated.override;
in
{
devShells.default = pkgs.mkShell shell;
}
));
}
@@ -0,0 +1,35 @@
{
pkgs,
lib,
config,
...
}:
with lib;
let
packages = config.python.packages;
pythonPackage = pkgs.python3.withPackages packages;
in
{
options.python = {
enable = mkEnableOption "Python";
packages = mkOption {
type = types.functionTo (types.listOf types.package) // {
merge =
loc: defs: p:
lib.concatMap (def: (def.value p)) defs;
};
default = p: [ ];
description = "Python packages to install";
};
# TODO: Add option to directly read from requirements.txt, maybe with mach-nix
};
config = mkIf config.python.enable {
packages = [
pythonPackage
];
env.PYTHONINTERPRETER = "${pythonPackage}/bin/python";
};
}
@@ -0,0 +1,37 @@
{
pkgs,
lib,
config,
...
}:
with lib;
let
rustPackage = pkgs.rustc;
in
{
options.rust = {
enable = mkEnableOption "Rust";
# TODO: Add option to specify toolchain file
# See https://ayats.org/blog/nix-rustup
};
config = mkIf config.rust.enable {
packages = with pkgs; [
rustPackage
cargo
clippy
rustfmt
cargo-audit
bacon
evcxr
# TODO: Might be needed for bindgen
# rustPlatform.bindgenHook
# pkg-config
];
# env.RUST_SRC_PATH = "${rustPackage}/lib/rustlib/src/rust/library";
};
}
+43
View File
@@ -0,0 +1,43 @@
{ lib, ... }:
with lib;
{
options = {
env = mkOption {
type = types.attrsOf types.str;
default = { };
};
packages = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Packages to install";
};
extraPackages = mkOption {
type = types.functionTo (types.listOf types.package) // {
merge =
loc: defs: p:
lib.concatMap (def: (def.value p)) defs;
};
default = p: [ ];
description = "Extra packages to install";
};
libPackages = mkOption {
type = types.functionTo (types.listOf types.package) // {
merge =
loc: defs: p:
lib.concatMap (def: (def.value p)) defs;
};
default = p: [ ];
description = "Packages to install and add to library path";
};
override = mkOption {
type = types.attrs;
default = { };
description = "Settings in the mkShell call to override";
};
};
}
@@ -0,0 +1,15 @@
{
lib,
config,
...
}:
with lib;
{
options.cuda = {
enable = mkEnableOption "CUDA";
};
config = mkIf config.cuda.enable {
};
}
@@ -0,0 +1,22 @@
{
lib,
config,
...
}:
with lib;
{
options.jupyter = {
enable = mkEnableOption "Jupyter";
};
config = mkIf config.jupyter.enable {
python.enable = mkDefault true;
python.packages =
p: with p; [
jupyter
notebook
ipykernel
];
};
}