Skip to content

Commit

Permalink
fix(system): properly configure jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
jalil-salame committed Oct 16, 2024
1 parent 3a11187 commit b49f332
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 119 deletions.
81 changes: 45 additions & 36 deletions flake-modules/example-vm.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
{ inputs, lib, ... }:
let
system = "x86_64-linux";
overlays = builtins.attrValues inputs.self.overlays;
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-original" ];
pkgs = import inputs.nixpkgs { inherit system overlays config; };
in
{
# Example vm configuration
flake.nixosConfigurations.vm =
let
system = "x86_64-linux";
overlays = builtins.attrValues inputs.self.overlays;
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-original" ];
pkgs = import inputs.nixpkgs { inherit system overlays config; };
in
lib.nixosSystem {
inherit system pkgs;
modules = [
inputs.self.nixosModules.vm # import vm module
{
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "en_US.UTF-8";
users.users.jdoe = {
password = "example";
isNormalUser = true;
extraGroups = [
"wheel"
"video"
"networkmanager"
];
flake.nixosConfigurations.vm = lib.nixosSystem {
inherit system pkgs;
modules = [
inputs.self.nixosModules.vm # import vm module
{
time.timeZone = "Europe/Berlin";
i18n.defaultLocale = "en_US.UTF-8";
users.users.jdoe = {
password = "example";
isNormalUser = true;
extraGroups = [
"wheel"
"video"
"networkmanager"
];
};
home-manager.users.jdoe = {
home = {
username = "jdoe";
homeDirectory = "/home/jdoe";
};
home-manager.users.jdoe = {
home = {
username = "jdoe";
homeDirectory = "/home/jdoe";
};
jhome = {
jhome = {
enable = true;
gui.enable = true;
dev = {
enable = true;
gui.enable = true;
dev.rust.enable = true;
rust.enable = true;
};
};
nix.registry.nixpkgs.flake = inputs.nixpkgs;
jconfig = {
};
nix.registry.nixpkgs.flake = inputs.nixpkgs;
# password is 'test' see module documentation for more options
services.jupyter.password = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'";
jconfig = {
enable = true;
dev = {
enable = true;
gui.enable = true;
jupyter.enable = true;
};
}
];
};
gui.enable = true;
};
}
];
};

}
177 changes: 95 additions & 82 deletions system/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,92 +26,105 @@ in
{ stylix = import ./stylix-config.nix { inherit config pkgs; }; }
];

config = lib.mkIf cfg.enable {
boot.plymouth.enable = cfg.styling.enable;
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
boot.plymouth = {
inherit (cfg.styling) enable;
};

# Enable unlocking the gpg-agent at boot (configured through home.nix)
security.pam.services.login.gnupg.enable = true;
# Enable unlocking the gpg-agent at boot (configured through home.nix)
security.pam.services.login.gnupg.enable = true;

environment.systemPackages = [
# CLI tools
pkgs.fd
pkgs.bat
pkgs.skim
pkgs.ripgrep
pkgs.du-dust
pkgs.curl
pkgs.wget
pkgs.eza
pkgs.zip
pkgs.unzip
];
environment.systemPackages = [
# CLI tools
pkgs.fd
pkgs.bat
pkgs.skim
pkgs.ripgrep
pkgs.du-dust
pkgs.curl
pkgs.wget
pkgs.eza
pkgs.zip
pkgs.unzip
];

# Enable dev documentation
documentation.dev.enable = cfg.dev.enable;
programs = {
# Shell prompt
starship = {
enable = true;
settings = lib.mkIf cfg.styling.enable {
format = "$time$all";
add_newline = false;
cmd_duration.min_time = 500;
cmd_duration.show_milliseconds = true;
time = {
format = "[$time](bold yellow) ";
disabled = false;
};
status = {
format = "[$signal_name$common_meaning$maybe_int](red)";
symbol = "[✗](bold red)";
disabled = false;
# Enable dev documentation
documentation.dev = {
inherit (cfg.dev) enable;
};
programs = {
# Shell prompt
starship = {
enable = true;
settings = {
format = "$time$all";
add_newline = false;
cmd_duration.min_time = 500;
cmd_duration.show_milliseconds = true;
time = {
format = "[$time](bold yellow) ";
disabled = false;
};
status = {
format = "[$signal_name$common_meaning$maybe_int](red)";
symbol = "[✗](bold red)";
disabled = false;
};
sudo.disabled = false;
};
};
sudo.disabled = false;
# Default shell
zsh.enable = true;
};
};
# Default shell
zsh.enable = true;
};

environment.etc = keysFromGithub;
services = {
# Enable printer autodiscovery if printing is enabled
avahi = {
inherit (config.services.printing) enable;
nssmdns4 = true;
openFirewall = true;
};
openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") (
builtins.attrNames keysFromGithub
);
jupyter = {
inherit (cfg.dev) enable;
group = "users";
};
};
users.defaultUserShell = pkgs.zsh;
# Open ports for spotifyd
networking.firewall = {
allowedUDPPorts = [ 5353 ];
allowedTCPPorts = [ 2020 ];
};
# Nix Settings
nix = {
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
# run between 0 and 45min after boot if run was missed
randomizedDelaySec = "45min";
};
settings = {
use-xdg-base-directories = true;
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
];
};
};
};
environment.etc = keysFromGithub;
services = {
# Enable printer autodiscovery if printing is enabled
avahi = {
inherit (config.services.printing) enable;
nssmdns4 = true;
openFirewall = true;
};
openssh.authorizedKeysFiles = builtins.map (path: "/etc/${path}") (
builtins.attrNames keysFromGithub
);
};
users.defaultUserShell = pkgs.zsh;
# Open ports for spotifyd
networking.firewall = {
allowedUDPPorts = [ 5353 ];
allowedTCPPorts = [ 2020 ];
};
# Nix Settings
nix = {
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
# run between 0 and 45min after boot if run was missed
randomizedDelaySec = "45min";
};
settings = {
use-xdg-base-directories = true;
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
];
};
};
}
# dev configuration
(lib.mkIf cfg.dev.enable {
users.extraUsers = lib.mkIf cfg.dev.jupyter.enable { jupyter.group = "jupyter"; };
services.jupyter = {
inherit (cfg.dev.jupyter) enable;
group = "jupyter";
user = "jupyter";
};
})
]
);
}
5 changes: 4 additions & 1 deletion system/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ let
dev = lib.mkOption {
description = "Options for setting up a dev environment";
default = { };
type = types.submodule { options.enable = lib.mkEnableOption "dev configuration"; };
type = types.submodule {
options.enable = lib.mkEnableOption "dev configuration";
options.jupyter.enable = lib.mkEnableOption "jupyter configuration";
};
};
gui = lib.mkOption {
description = "Jalil's default configuration for a NixOS gui.";
Expand Down

0 comments on commit b49f332

Please sign in to comment.