Compare commits

...

5 Commits

Author SHA1 Message Date
Jan-Bulthuis e2abde8b28 Changes 2025-02-09 01:11:07 +01:00
Jan-Bulthuis f1f4255d7d Moved env to shell 2025-02-08 23:25:05 +01:00
Jan-Bulthuis 944d74060e Added env helper 2025-02-08 23:16:50 +01:00
Jan-Bulthuis ffc4e6a90b Fixed typo 2025-02-08 23:07:08 +01:00
Jan-Bulthuis 47c7b69afa Added python skeleton 2025-02-08 23:06:32 +01:00
9 changed files with 167 additions and 50 deletions

View File

@ -210,6 +210,24 @@
} }
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": { "inputs": {
"systems": [ "systems": [
"stylix", "stylix",
@ -589,7 +607,7 @@
}, },
"nuschtosSearch": { "nuschtosSearch": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"ixx": "ixx", "ixx": "ixx",
"nixpkgs": [ "nixpkgs": [
"nixvim", "nixvim",
@ -612,6 +630,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-matlab": "nix-matlab", "nix-matlab": "nix-matlab",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
@ -628,12 +647,12 @@
"base16-vim": "base16-vim", "base16-vim": "base16-vim",
"firefox-gnome-theme": "firefox-gnome-theme", "firefox-gnome-theme": "firefox-gnome-theme",
"flake-compat": "flake-compat_3", "flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_3",
"git-hooks": "git-hooks_2", "git-hooks": "git-hooks_2",
"gnome-shell": "gnome-shell", "gnome-shell": "gnome-shell",
"home-manager": "home-manager_3", "home-manager": "home-manager_3",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_3",
"systems": "systems_2", "systems": "systems_3",
"tinted-foot": "tinted-foot", "tinted-foot": "tinted-foot",
"tinted-kitty": "tinted-kitty", "tinted-kitty": "tinted-kitty",
"tinted-tmux": "tinted-tmux", "tinted-tmux": "tinted-tmux",
@ -683,6 +702,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tinted-foot": { "tinted-foot": {
"flake": false, "flake": false,
"locked": { "locked": {

View File

@ -17,10 +17,12 @@
url = "gitlab:doronbehar/nix-matlab"; url = "gitlab:doronbehar/nix-matlab";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = outputs =
{ {
self,
nixpkgs, nixpkgs,
home-manager, home-manager,
stylix, stylix,
@ -67,6 +69,6 @@
}; };
}; };
}; };
devenv = ./shell-modules/default.nix; lib = import ./shell-modules/default.nix self.inputs;
}; };
} }

View File

@ -1,35 +1,42 @@
{ pkgs, ... }: {
nixpkgs,
flake-utils,
...
}:
pkgs.mkShell { let
packages = with pkgs; [ imports = [
(python312.withPackages (p: [ ./shell.nix
p.numpy ./languages/python.nix
p.scikit-learn ./utilities/cuda.nix
p.scipy
p.pandas
p.matplotlib
p.torch-bin
# p.torchvision
]))
libffi
openssl
stdenv.cc.cc
linuxPackages.nvidia_x11
binutils
cudatoolkit
libGLU
libGL
]; ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ( in
with pkgs; {
[
stdenv.cc.cc mkShell =
linuxPackages.nvidia_x11 attrs:
binutils (flake-utils.lib.eachDefaultSystem (
cudatoolkit system:
libGLU let
libGL pkgs = import nixpkgs {
] inherit system;
); config.allowUnfree = true;
CUDA_PATH = pkgs.cudatoolkit; };
evaluated =
(nixpkgs.lib.evalModules {
modules = [ attrs ] ++ imports;
specialArgs = {
pkgs = pkgs;
};
}).config;
recUpdate = nixpkgs.lib.recursiveUpdate;
shell = recUpdate {
env = evaluated.env;
packages = evaluated.packages ++ (evaluated.extraPackages pkgs);
} evaluated.override;
in
{
devShells.default = pkgs.mkShell shell;
}
));
} }

View File

@ -0,0 +1,35 @@
{
pkgs,
lib,
config,
...
}:
with lib;
{
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 =
with pkgs;
let
packages = config.python.packages;
pythonPackage = python3.withPackages packages;
in
[
pythonPackage
];
};
}

33
shell-modules/shell.nix Normal file
View File

@ -0,0 +1,33 @@
{ 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";
};
override = mkOption {
type = types.attrs;
default = { };
description = "Settings in the mkShell call to override";
};
};
}

View File

@ -0,0 +1,17 @@
{
pkgs,
lib,
config,
...
}:
with lib;
{
options.cuda = {
enable = mkEnableOption "CUDA";
};
config = mkIf config.cuda.enable {
};
}

View File

@ -4,6 +4,8 @@
imports = [ imports = [
./ide/mathematica.nix ./ide/mathematica.nix
./ide/matlab.nix ./ide/matlab.nix
# TODO: Move languages to make clear it is just IDE configuration
# Languages should be installed with devShells, however the IDE must be configured globally
./language/cpp.nix ./language/cpp.nix
./language/haskell.nix ./language/haskell.nix
./language/js.nix ./language/js.nix

View File

@ -8,7 +8,6 @@
with lib; with lib;
let let
cfg = config.modules.python; cfg = config.modules.python;
package = pkgs.python3.withPackages cfg.extraPythonPackages;
in in
{ {
options.modules.python = { options.modules.python = {
@ -26,9 +25,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
# Development packages # Development packages
home.packages = [ home.packages = [ ];
package
];
# Allow unfree # Allow unfree
modules.unfree.allowedPackages = [ modules.unfree.allowedPackages = [

View File

@ -109,16 +109,6 @@
tex.enable = true; tex.enable = true;
jupyter.enable = true; jupyter.enable = true;
# python.extraPythonPackages = p: [
# p.numpy
# p.scikit-learn
# p.scipy
# p.pandas
# p.matplotlib
# p.torch
# p.torchvision
# ];
# Enable unfree # Enable unfree
unfree.enable = true; unfree.enable = true;
}; };