Hi,
How can I import a module from my nixos configuration into nix repl
?
I have the module
{ config, options, lib, pkgs, ... }:
with lib;
let devCfg = config.modules.dev;
cfg = devCfg.python;
in {
options.modules.dev.python = with types; {
enable = mkEnableOption "python";
xdg.enable = mkOption {
type = bool;
default = devCfg.xdg.enable;
};
};
config = mkMerge [
(mkIf cfg.enable {
user.packages = with pkgs; [
python3
];
environment.shellAliases = {
py = python3;
};
})
(mkIf cfg.xdg.enable {
env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc";
})
];
}
In nix repl
I can load my systems flake and call the module function. But how can I easily give the attribute set when calling/loading the module, eg. something like
:lf /etc/nixos
# added 20 variables, like my libs, inputs, ...
py = nixosModules.dev.python { inherit config, options, lib, pkgs;}
#or
py = import /etc/nixos/modules/dev/python.nix { inherit config options lib pkgs;}
:p py.config.contents
But for this to work I need to do some tweaking
mylib = lib
lib = mylib.extend (_: _: inputs.nixpkgs.lib )
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux
config = nixosConfigurations.HOST.config
options = nixosConfigurations.HOST.options
Is there a better way to peek into a module from my configuration?
Addendum:
I want to do this for leaning and easier debugging. Lets say I have
modules/dev/test.nix
{ config, options, lib, pkgs, ... }:
with lib;
let cfg = config.modules.dev;
in {
options.modules.dev = {
test.enable = mkOption { default = true; };
};
config = mkIf cfg.test.enable {
b = trace (3+3) true;
};
}
I would like to see the output of the trace.