Skip to content

Commit

Permalink
Working on subpackages settings
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Oct 23, 2024
1 parent e3a10b3 commit 31d83ec
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 17 deletions.
4 changes: 3 additions & 1 deletion modules/kernels/coq/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,7 +16,9 @@ with lib;
example = "List of Coq packages to use";
type = types.listOf types.str;
default = [];
visible = false;
};

coqPackages = mkOption {
example = "Coq packages set";
type = types.enum (
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/cpp/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,6 +16,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

flavor = mkOption {
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/go/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,6 +16,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

goPackage = mkOption {
Expand Down
4 changes: 3 additions & 1 deletion modules/kernels/haskell/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,7 +16,9 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

ghcPackage = mkOption {
example = "GHC version";
type = types.enum ["ghc92" "ghc94" "ghc96" "ghc98"];
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/julia/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,6 +16,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

juliaPackage = mkOption {
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/octave/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,6 +16,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

interface.attrs = mkOption {
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/postgres/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -15,6 +15,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

interface.attrs = mkOption {
Expand Down
14 changes: 13 additions & 1 deletion modules/kernels/python/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ let

packages = mkOption {
example = "List of packages";
type = types.listOf types.str;
type = types.listOf (types.either types.str (types.submodule {
options = {
name = mkOption {
description = "Package name";
type = types.str;
};
outputs = mkOption {
example = "Package outputs to include";
type = types.listOf types.str;
};
};
}));
default = [];
visible = false;
};

python3Package = packageOption;
Expand Down
3 changes: 2 additions & 1 deletion modules/kernels/r/module.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, nixosOptionsToSettingsSchema, boilerplate, ... }:
{ config, options, lib, nixosOptionsToSettingsSchema, boilerplate, ... }:

with lib;

Expand All @@ -16,6 +16,7 @@ with lib;
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

interface.attrs = mkOption {
Expand Down
1 change: 1 addition & 0 deletions modules/kernels/ruby/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ in
example = "List of packages";
type = types.listOf types.str;
default = [];
visible = false;
};

rubyPackage = mkOption {
Expand Down
4 changes: 2 additions & 2 deletions modules/kernels/rust/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ with lib;
example = "List of packages";
type = types.listOf (types.either types.str (types.submodule {
options = {
name = mkOption rec {
name = mkOption {
description = "Package name";
type = types.str;
};
features = mkOption rec {
features = mkOption {
example = "Features to enable for the package";
type = types.listOf types.str;
};
Expand Down
14 changes: 9 additions & 5 deletions nix/makeEnvironment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ let

mkSubPackageMetadata = pkg: p: {
name = packageName p;
meta = if lib.hasAttrByPath ["packageOptions" (packageName p)] pkg then chooseMeta (pkg.packageOptions.${packageName p}) else {};
} // (lib.optionalAttrs (lib.isAttrs p && p ? "settings") {
inherit (p) settings;
});
meta = let
meta = chooseMeta (pkg.packageOptions.${packageName p} or {});
settings = if lib.isAttrs p then lib.removeAttrs p ["name"] else {};
in
meta // (lib.optionalAttrs (builtins.length (builtins.attrNames settings) != 0) {
inherit settings;
});
};
in
pkg: {
# Dry
name = pkg.name;
settings = pkg.settings or {};
settings = lib.removeAttrs (pkg.settings or {}) ["packages"];

# Different for hydrated
packages = map (p: mkSubPackageMetadata pkg p) (pkg.settings.packages or []);
Expand Down
5 changes: 4 additions & 1 deletion sample_environments/python3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
codedown.makeEnvironment {
kernels.python3.enable = true;
kernels.python3.packages = [
"matplotlib"
{
name = "matplotlib";
outputs = ["out" "dist"];
}
"scipy"
"rope"
];
Expand Down

0 comments on commit 31d83ec

Please sign in to comment.