Unified home and system modules!

This commit is contained in:
marc
2022-11-19 11:58:21 +01:00
parent cfcc374a69
commit 890b05d352
45 changed files with 389 additions and 566 deletions

View File

@@ -32,9 +32,7 @@
specialArgs = { inherit lib inputs system; }; specialArgs = { inherit lib inputs system; };
modules = [ modules = [
./system/modules ./hosts/reykjavik
./system/profiles
./system/hosts/reykjavik
{ {
imports = imports =
@@ -43,44 +41,28 @@
++ (lib.my.mapModulesRec' (toString ./modules) import); ++ (lib.my.mapModulesRec' (toString ./modules) import);
} }
];
};
# - Kopavogur ----------------------------
kopavogur = lib.nixosSystem {
inherit system;
inherit pkgs;
specialArgs = { inherit lib inputs system; };
modules = [
./hosts/kopavogur
{ {
home-manager.users.marc = { imports =
imports = [ [ inputs.home-manager.nixosModules.home-manager ]
./home/modules # All my personal modules
./home/profiles ++ (lib.my.mapModulesRec' (toString ./modules) import);
./home/hosts/reykjavik.nix
];
};
} }
]; ];
}; };
# - Kopavogur ----------------------------
# kopavogur = lib.nixosSystem {
# inherit system;
# inherit pkgs;
# modules = [
# ./system/modules
# ./system/profiles
# ./system/hosts/kopavogur
# home-manager.nixosModules.home-manager {
# home-manager.useGlobalPkgs = true;
# home-manager.useUserPackages = true;
# home-manager.users.marc = {
# imports = [
# ./home/modules
# ./home/profiles
# ./home/hosts/kopavogur.nix
# ];
# };
# }
# ];
# };
}; };
}; };
} }

View File

@@ -1,11 +0,0 @@
{ ... }:
{
home.stateVersion = "22.05";
samfelag = {
profiles = {
desktop.enable = true;
};
};
}

View File

@@ -1,19 +0,0 @@
{ ... }:
{
home.stateVersion = "22.05";
samfelag = {
modules = {
app = {
discord.enable = true;
spotify.enable = true;
};
editors.emacs.enable = true;
};
profiles = {
desktop.enable = true;
gaming.enable = true;
};
};
}

View File

@@ -1,9 +0,0 @@
{ ... }:
{
imports = [
# ./alacritty.nix
./discord.nix
./spotify.nix
];
}

View File

@@ -1,11 +0,0 @@
{ ... }:
{
imports = [
./app
./desktop
./dev
./editors
./shell
];
}

View File

@@ -1,8 +0,0 @@
{ ... }:
{
imports = [
./i3.nix
./polybar.nix
];
}

View File

@@ -1,7 +0,0 @@
{ ... }:
{
imports = [
./git.nix
];
}

View File

@@ -1,24 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.dev.git;
in {
options.samfelag.modules.dev.git = {
enable = lib.mkEnableOption "git config";
};
config = lib.mkIf cfg.enable {
programs.git = {
enable = true;
userName = "marc";
userEmail = "marc@sastre.cat";
extraConfig = {
init.defaultBranch = "main";
};
};
};
}

View File

@@ -1,7 +0,0 @@
{ ... }:
{
imports = [
./emacs.nix
];
}

View File

@@ -1,14 +0,0 @@
{ config, inputs, lib, options, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.editors.emacs;
in {
options.samfelag.modules.editors.emacs = {
enable = mkEnableOption "emacs";
};
config = mkIf cfg.enable {
# xdg.configFile."doom".src = ../../../config/doom;
};
}

View File

@@ -1,30 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.shell;
in
{
imports = [
./zsh.nix
];
options.samfelag.modules.shell = {
enable = mkEnableOption "Basic shell config";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
bat
exa
fd
fzf
jq
ripgrep
tldr
];
xdg.configFile."shell".source = ../../../config/.config/shell;
};
}

View File

@@ -1,17 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
{
samfelag.modules = {
shell = {
enable = true;
zsh = {
enable = true;
};
};
dev.git.enable = true;
};
}

View File

@@ -1,9 +0,0 @@
{ ... }:
{
imports = [
./common.nix
./desktop.nix
./gaming.nix
];
}

View File

@@ -1,49 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.profiles.desktop;
laptopPkgs = with pkgs; [
];
in
{
options.samfelag.profiles.desktop = {
enable = mkEnableOption "desktop profile";
laptop = mkOption {
description = "Add packages required when machine is a laptop";
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
# - Dependencies -----------------------------
samfelag.modules = {
desktop = {
i3 = {
enable = true;
launcher.command = "${pkgs.rofi}/bin/rofi rofi -show run";
terminal.command = "${pkgs.alacritty}/bin/alacritty";
browser.command = "${pkgs.firefox}/bin/firefox";
locker.command = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1";
};
polybar.enable = true;
};
};
services.picom.enable = true;
home.packages = with pkgs; [
rofi
firefox
brightnessctl
playerctl
feh
] ++ optionals cfg.laptop laptopPkgs;
};
}

View File

@@ -1,24 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.profiles.gaming;
in
{
options.samfelag.profiles.gaming = {
enable = mkEnableOption "gaming profile";
};
config = mkIf cfg.enable {
# - Dependencies -----------------------------
samfelag.modules = {
};
home.packages = with pkgs; [
lutris
];
};
}

View File

@@ -0,0 +1,46 @@
{ config, pkgs, lib, ... }:
{
imports = [
./hardware.nix
];
# - Basic --------------------------------------
user.name = "marc";
user.shell = pkgs.zsh;
networking.hostName = "kopavogur";
# - Bootloader ---------------------------------
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useOSProber = true;
# - Modules ------------------------------------
samfelag.modules = {
# - Common -----------------------------------
# See modules/common.nix for common packages installed
# - System -----------------------------------
# - Desktop ----------------------------------
desktop = {
enable = true;
laptop = true;
};
# - Editors and development ------------------
editors.emacs.enable = true;
dev.git.userName = "marc";
dev.git.userEmail = "marc@sastre.cat";
# - Other apps -------------------------------
app.spotify.enable = true;
};
}

View File

@@ -0,0 +1,50 @@
{ config, pkgs, lib, ... }:
{
imports = [
./hardware.nix
./nvidia.nix
];
# - Basic --------------------------------------
user.name = "marc";
user.shell = pkgs.zsh;
networking.hostName = "reykjavik";
# - Bootloader ---------------------------------
boot.loader.systemd-boot.enable = true;
# - Modules ------------------------------------
samfelag.modules = {
# - Common -----------------------------------
# See modules/common.nix for common packages installed
# - System -----------------------------------
system.bluetooth.enable = true;
# - Desktop ----------------------------------
desktop = {
enable = true;
laptop = true;
};
# - Editors and development ------------------
editors.emacs.enable = true;
dev.git.userName = "marc";
dev.git.userEmail = "marc@sastre.cat";
# - Other apps -------------------------------
app.spotify.enable = true;
# - Gaming -----------------------------------
gaming.lutris.enable = true;
gaming.steam.enable = true;
app.discord.enable = true;
};
}

View File

@@ -1,21 +1,18 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.samfelag.modules.app.alacritty; cfg = config.samfelag.modules.app.alacritty;
in in
{ {
options.samfelag.modules.app.alacritty = { options.samfelag.modules.app.alacritty = {
enable = mkEnableOption "alacritty"; enable = lib.mkEnableOption "alacritty";
}; };
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = with pkgs; [ hm.home.packages = with pkgs; [
alacritty alacritty
(nerdfonts.override { fonts = [ "Iosevka" ]; }) (nerdfonts.override { fonts = [ "Iosevka" ]; })
]; ];
hm.xdg.configFile."alacritty".source = ../../config/.config/alacritty;
home.configFile."alacritty".source = ../../config/.config/alacritty;
}; };
} }

View File

@@ -10,7 +10,7 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = with pkgs; [ hm.home.packages = with pkgs; [
discord discord
]; ];
}; };

View File

@@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.samfelag.modules.app.spotify; cfg = config.samfelag.modules.app.spotify;
in in
{ {
options.samfelag.modules.app.spotify = { options.samfelag.modules.app.spotify = {
enable = mkEnableOption "spotify"; enable = lib.mkEnableOption "spotify";
}; };
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable { hm.home.packages = with pkgs; [
home.packages = with pkgs; [
spotify spotify
]; ];
}; };

View File

@@ -1,8 +1,15 @@
# Common module
# -------------
# All configuration common to ANY host is located here.
# General configuration and "bare minimum" tools
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
# - Nix ---------------------------------------- # - Nix ----------------------------------------
system.stateVersion = "22.05";
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
@@ -37,15 +44,19 @@
pciutils pciutils
psmisc psmisc
vim vim
zsh
]; ];
# - Other -------------------------------------- # - Modules ------------------------------------
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
networking.firewall.checkReversePath = "loose"; # See https://github.com/tailscale/tailscale/issues/4432
samfelag.modules.tailscale.enable = true;
system.stateVersion = "22.05"; samfelag.modules = {
shell.utils.enable = true;
shell.zsh.enable = true;
dev.git.enable = true;
# May go away from common if not all hosts use it
system.tailscale.enable = true;
};
} }

View File

@@ -0,0 +1,68 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.desktop;
laptopPkgs = with pkgs; [
];
in
{
options.samfelag.modules.desktop = {
enable = mkEnableOption "desktop environment";
laptop = mkOption {
description = "Enable features for a laptop (trackpad, battery, etc...)";
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
# - Packages ---------------------------------
environment.systemPackages = with pkgs; [
pamixer
i3lock-blur
brightnessctl
playerctl
feh
rofi
firefox
] ++ optionals cfg.laptop laptopPkgs;
# - Audio ------------------------------------
sound.enable = true;
hardware = {
pulseaudio = {
enable = true;
support32Bit = true;
package = pkgs.pulseaudioFull;
};
};
# - Compositor -------------------------------
services.picom.enable = true;
# - Modules ----------------------------------
samfelag.modules = {
app.alacritty.enable = true;
desktop.polybar.enable = true;
desktop.i3 = {
enable = true;
laptop = cfg.laptop;
launcher.command = "${pkgs.rofi}/bin/rofi rofi -show run";
terminal.command = "${pkgs.alacritty}/bin/alacritty";
browser.command = "${pkgs.firefox}/bin/firefox";
locker.command = "${pkgs.i3lock-blur}/bin/i3lock-color -c 808F85 && sleep 1";
};
};
};
}

View File

@@ -1,6 +1,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
cfg = config.samfelag.modules.desktop.i3; cfg = config.samfelag.modules.desktop.i3;
mod = "Mod4"; mod = "Mod4";
@@ -18,12 +18,24 @@ let
}); });
system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"; system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown";
bg_colour = "#808F85"; bg_colour = "#808F85";
paths = {
wallpapers = ../../data/wallpapers;
};
in { in {
options.samfelag.modules.desktop.i3 = { options.samfelag.modules.desktop.i3 = {
enable = lib.mkEnableOption "i3 window manager"; enable = lib.mkEnableOption "i3 window manager";
laptop = lib.mkOption {
description = "Enable features for a laptop (trackpad, battery, etc...)";
type = lib.types.bool;
default = false;
};
launcher = lib.mkOption { launcher = lib.mkOption {
type = cmdModule; type = cmdModule;
}; };
@@ -42,15 +54,45 @@ in {
# - Dependencies ----------------------------- # - Dependencies -----------------------------
home.packages = with pkgs; [ environment.systemPackages = with pkgs; [
(nerdfonts.override { fonts = [ "Iosevka" ]; }) (nerdfonts.override { fonts = [ "Iosevka" ]; })
]; ];
xdg.dataFile."wallpapers".source = ../../../data/wallpapers; hm.xdg.dataFile."wallpapers".source = paths.wallpapers;
services.xserver = {
enable = true;
libinput = lib.mkIf cfg.laptop {
enable = true;
touchpad.tapping = true;
};
desktopManager = {
xterm.enable = false;
};
displayManager = {
defaultSession = "none+i3";
lightdm = {
enable = true;
greeters.mini = {
enable = true;
user = "marc";
extraConfig = ''
[greeter]
show-sys-info = true
'';
};
};
};
windowManager.i3.enable = true;
};
# - Configuration ---------------------------- # - Configuration ----------------------------
xsession.windowManager.i3 = { hm.xsession.windowManager.i3 = {
enable = true; enable = true;
config = { config = {
@@ -64,7 +106,7 @@ in {
focus.followMouse = false; focus.followMouse = false;
bars = [ ]; bars = [ ];
window = { window = {
border = 1; border = 1;
@@ -76,11 +118,10 @@ in {
# outer = 5; # outer = 5;
# }; # };
startup = [ startup = [
{ command = "i3-msg workspace 1"; } { command = "i3-msg workspace 1"; }
{ command = "systemctl --user restart polybar"; always = true; notification = false; } { command = "systemctl --user restart polybar"; always = true; notification = false; }
{ command = "feh --bg-center -B \"${bg_colour}\" -z --no-fehbg ${config.xdg.dataFile.wallpapers.source}/flors"; always = true; notification = false; } { command = "feh --bg-center -B \"${bg_colour}\" -z --no-fehbg ${paths.wallpapers}/flors"; always = true; notification = false; }
]; ];
modes = { modes = {
@@ -89,17 +130,17 @@ in {
"j" = "resize grow height 10 px or 10 ppt"; "j" = "resize grow height 10 px or 10 ppt";
"k" = "resize shrink height 10 px or 10 ppt"; "k" = "resize shrink height 10 px or 10 ppt";
"l" = "resize grow width 10 px or 10 ppt"; "l" = "resize grow width 10 px or 10 ppt";
"Left" = "resize shrink width 10 px or 10 ppt"; "Left" = "resize shrink width 10 px or 10 ppt";
"Down" = "resize grow height 10 px or 10 ppt"; "Down" = "resize grow height 10 px or 10 ppt";
"Up" = "resize shrink height 10 px or 10 ppt"; "Up" = "resize shrink height 10 px or 10 ppt";
"Right" = "resize grow width 10 px or 10 ppt"; "Right" = "resize grow width 10 px or 10 ppt";
"Return" = "mode \"default\""; "Return" = "mode \"default\"";
"Escape" = "mode \"default\""; "Escape" = "mode \"default\"";
}; };
"${system_mode}" = { "${system_mode}" = {
"l" = "exec --no-startup-id ${cfg.locker.command}, mode \"default\""; "l" = "exec --no-startup-id ${cfg.locker.command}, mode \"default\"";
"e" = "exec --no-startup-id i3-msg exit, mode \"default\""; "e" = "exec --no-startup-id i3-msg exit, mode \"default\"";
"s" = "exec --no-startup-id ${cfg.locker.command} && systemctl suspend, mode \"default\""; "s" = "exec --no-startup-id ${cfg.locker.command} && systemctl suspend, mode \"default\"";
@@ -138,18 +179,18 @@ in {
# split orientation # split orientation
"${mod}+z" = "split h;exec notify-send 'tile horizontally'"; "${mod}+z" = "split h;exec notify-send 'tile horizontally'";
"${mod}+v" = "split v;exec notify-send 'tile vertically'"; "${mod}+v" = "split v;exec notify-send 'tile vertically'";
# enter fullscreen mode for the focused container # enter fullscreen mode for the focused container
"${mod}+f" = "fullscreen toggle"; "${mod}+f" = "fullscreen toggle";
# change container layout (stacked, tabbed, toggle split) # change container layout (stacked, tabbed, toggle split)
"${mod}+s" = "layout stacking"; "${mod}+s" = "layout stacking";
"${mod}+w" = "layout tabbed"; "${mod}+w" = "layout tabbed";
"${mod}+e" = "layout toggle split"; "${mod}+e" = "layout toggle split";
# toggle tiling / floating # toggle tiling / floating
"${mod}+Shift+space" = "floating toggle"; "${mod}+Shift+space" = "floating toggle";
# focus the parent container # focus the parent container
"${mod}+a" = "focus parent"; "${mod}+a" = "focus parent";
@@ -163,18 +204,18 @@ in {
# - Media ------------------------------ # - Media ------------------------------
# Pulse Audio controls # Pulse Audio controls
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%"; "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%"; "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%";
"Shift+XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1%"; "Shift+XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1%";
"Shift+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%"; "Shift+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%";
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle"; "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
# Media player controls # Media player controls
"XF86AudioPlay" = "exec playerctl play-pause"; "XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioPause" = "exec playerctl play-pause"; "XF86AudioPause" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next"; "XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous"; "XF86AudioPrev" = "exec playerctl previous";
"XF86AudioStop" = "exec playerctl stop"; "XF86AudioStop" = "exec playerctl stop";
# - Workspaces ------------------------- # - Workspaces -------------------------

View File

@@ -10,6 +10,12 @@ let
polybar top & polybar top &
polybar bottom & polybar bottom &
''; '';
# Paths
paths = {
config = ../../config/.config/polybar/config.ini;
bars = ../../config/.config/polybar/bars;
scripts = ../../config/.config/polybar/scripts;
};
in { in {
options.samfelag.modules.desktop.polybar = { options.samfelag.modules.desktop.polybar = {
@@ -20,19 +26,19 @@ in {
# - Configuration ---------------------------- # - Configuration ----------------------------
home.packages = [ environment.systemPackages = [
polybar_pkg polybar_pkg
]; ];
xdg.configFile."polybar/config.ini".source = ../../../config/.config/polybar/config.ini; hm.xdg.configFile."polybar/config.ini".source = paths.config;
xdg.configFile."polybar/bars".source = ../../../config/.config/polybar/bars; hm.xdg.configFile."polybar/bars".source = paths.bars;
xdg.configFile."polybar/scripts".source = ../../../config/.config/polybar/scripts; hm.xdg.configFile."polybar/scripts".source = paths.scripts;
systemd.user.services.polybar = { hm.systemd.user.services.polybar = {
Unit = { Unit = {
Description = "Polybar status bar"; Description = "Polybar status bar";
PartOf = [ "tray.target" ]; PartOf = [ "tray.target" ];
X-Restart-Triggers = [ "${config.xdg.configFile."polybar/config.ini".source}" ]; X-Restart-Triggers = [ "${paths.config}" ];
}; };
Service = { Service = {

27
modules/dev/git.nix Normal file
View File

@@ -0,0 +1,27 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.dev.git;
in
{
options.samfelag.modules.dev.git = with lib.types; {
enable = lib.mkEnableOption "git";
userName = lib.my.mkOpt str config.user.name;
userEmail = lib.my.mkOpt (nullOr str) null;
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
git
];
hm.programs.git = {
enable = true;
userName = cfg.userName;
userEmail = cfg.userEmail;
extraConfig = {
init.defaultBranch = "main";
};
};
};
}

View File

@@ -92,20 +92,9 @@ in {
fonts.fonts = [ pkgs.emacs-all-the-icons-fonts ]; fonts.fonts = [ pkgs.emacs-all-the-icons-fonts ];
# env.PATH = [ "$XDG_CONFIG_HOME/emacs/bin" ]; env.PATH = [ "$XDG_CONFIG_HOME/emacs/bin" ];
environment.sessionVariables = rec { home-manager.users.marc.xdg.configFile."doom".source = ../../config/doom;
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_BIN_HOME = "$HOME/.local/bin";
XDG_DATA_HOME = "$HOME/.local/share";
PATH = [
"$HOME/.config/emacs/bin"
];
};
home-manager.users.marc.xdg.configFile."doom".source = ../../../config/doom;
system.userActivationScripts = { system.userActivationScripts = {
installDoomEmacs = '' installDoomEmacs = ''
@@ -113,7 +102,7 @@ in {
echo $XDG_CONFIG_HOME echo $XDG_CONFIG_HOME
echo $EMACS_FOLDER echo $EMACS_FOLDER
if [ ! -d "$EMACS_FOLDER" ]; then if [ ! -d "$EMACS_FOLDER" ]; then
${pkgs.git}/bin/git clone --depth=1 --single-branch "https://github.com/doomemacs/doomemacs" "$EMACS_FOLDER" ${pkgs.git}/bin/git clone --depth=1 --single-branch "https://github.com/doomemacs/doomemacs" "$EMACS_FOLDER"
fi fi
''; '';
}; };

15
modules/gaming/lutris.nix Normal file
View File

@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.gaming.lutris;
in
{
options.samfelag.modules.gaming.lutris = {
enable = lib.mkEnableOption "lutris";
};
config = lib.mkIf cfg.enable {
hm.home.packages = with pkgs; [
lutris
];
};
}

View File

@@ -1,14 +1,12 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.samfelag.profiles.gaming; cfg = config.samfelag.modules.gaming.steam;
in in
{ {
options.samfelag.profiles.gaming = { options.samfelag.modules.gaming.steam = {
enable = lib.mkEnableOption "steam";
enable = lib.mkEnableOption "gaming profile";
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.steam = { programs.steam = {
enable = true; enable = true;

View File

@@ -6,12 +6,7 @@ with lib.my;
options = with types; { options = with types; {
user = mkOpt attrs {}; user = mkOpt attrs {};
home = { hm = mkOpt attrs {};
packages = mkOpt' (listOf package) [] "Packages to be installed at user level";
file = mkOpt' attrs {} "Files to place directly in $HOME" ;
configFile = mkOpt' attrs {} "Files to place in $XDG_CONFIG_HOME";
dataFile = mkOpt' attrs {} "Files to place in $XDG_DATA_HOME";
};
env = mkOption { env = mkOption {
# env = { PATH = ["$PATH" ./test]; TEST = "test"; } # env = { PATH = ["$PATH" ./test]; TEST = "test"; }
@@ -36,26 +31,6 @@ with lib.my;
uid = 1000; uid = 1000;
}; };
home-manager = {
# extraSpecialArgs = { inherit inputs; };
useGlobalPkgs = true;
useUserPackages = true;
users.${config.user.name} = {
home = {
file = mkAliasDefinitions options.home.file;
packages = mkAliasDefinitions options.home.packages;
# Necessary for home-manager to work with flakes, otherwise it will
# look for a nixpkgs channel.
stateVersion = config.system.stateVersion;
};
xdg = {
configFile = mkAliasDefinitions options.home.configFile;
dataFile = mkAliasDefinitions options.home.dataFile;
};
};
};
users.users.${config.user.name} = mkAliasDefinitions options.user; users.users.${config.user.name} = mkAliasDefinitions options.user;
nix.settings = let users = [ "root" config.user.name ]; in { nix.settings = let users = [ "root" config.user.name ]; in {
@@ -63,6 +38,16 @@ with lib.my;
allowed-users = users; allowed-users = users;
}; };
hm.home.stateVersion = config.system.stateVersion;
home-manager = {
# extraSpecialArgs = { inherit inputs; };
useGlobalPkgs = true;
useUserPackages = true;
users.${config.user.name} = mkAliasDefinitions options.hm;
};
env.PATH = [ "$PATH" ]; env.PATH = [ "$PATH" ];
environment.extraInit = environment.extraInit =

22
modules/shell/utils.nix Normal file
View File

@@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.shell.utils;
in
{
options.samfelag.modules.shell.utils = {
enable = lib.mkEnableOption "Basic shell utils";
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
bat
exa
fd
fzf
jq
ripgrep
tldr
];
hm.xdg.configFile."shell".source = ../../config/.config/shell;
};
}

View File

@@ -1,23 +1,21 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.samfelag.modules.shell.zsh; cfg = config.samfelag.modules.shell.zsh;
in in
{ {
options.samfelag.modules.shell.zsh = { options.samfelag.modules.shell.zsh = {
enable = mkEnableOption "zsh configuration"; enable = lib.mkEnableOption "zsh";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
home.packages = with pkgs; [
zsh zsh
zsh-powerlevel10k zsh-powerlevel10k
(nerdfonts.override { fonts = [ "Iosevka" ]; }) (nerdfonts.override { fonts = [ "Iosevka" ]; })
]; ];
programs.zsh = { hm.programs.zsh = {
enable = true; enable = true;
dotDir = ".config/zsh"; dotDir = ".config/zsh";
@@ -32,7 +30,7 @@ in
emulate bash -c ". $rc" emulate bash -c ". $rc"
done done
fi fi
# Source zsh specific configuration # Source zsh specific configuration
if [[ -d $HOME/.config/shell/zsh ]]; then if [[ -d $HOME/.config/shell/zsh ]]; then
for rc in $HOME/.config/shell/zsh/*.zsh; do for rc in $HOME/.config/shell/zsh/*.zsh; do
@@ -64,7 +62,7 @@ in
]; ];
}; };
xdg.configFile."zsh/.p10k.zsh".source = ../../../config/.config/zsh/.p10k.zsh; hm.xdg.configFile."zsh/.p10k.zsh".source = ../../config/.config/zsh/.p10k.zsh;
}; };
} }

View File

@@ -1,17 +1,14 @@
{ config, lib, pkgs, self, ... }: { config, lib, pkgs, self, ... }:
let let
cfg = config.samfelag.modules.bluetooth; cfg = config.samfelag.modules.system.bluetooth;
in in
{ {
options.samfelag.modules.bluetooth = { options.samfelag.modules.system.bluetooth = {
enable = lib.mkEnableOption "bluetooth"; enable = lib.mkEnableOption "bluetooth";
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
services.blueman.enable = true; services.blueman.enable = true;
}; };
} }

View File

@@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.system.tailscale;
in
{
options.samfelag.modules.system.tailscale = {
enable = lib.mkEnableOption "tailscale";
};
config = lib.mkIf cfg.enable {
# See https://github.com/tailscale/tailscale/issues/4432
networking.firewall.checkReversePath = "loose";
services.tailscale.enable = true;
};
}

View File

@@ -1,28 +0,0 @@
{ config, pkgs, lib, ... }:
{
imports = [
./hardware.nix
];
# - Basic --------------------------------------
networking.hostName = "kopavogur";
# samfelag.modules.user = {
# name = "marc";
# };
# - Bootloader ---------------------------------
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useOSProber = true;
# - Services -----------------------------------
samfelag.profiles.desktop.enable = true;
system.stateVersion = "22.05";
}

View File

@@ -1,37 +0,0 @@
{ config, pkgs, lib, ... }:
{
imports = [
./hardware.nix
./nvidia.nix
];
# - Basic --------------------------------------
user.name = "marc";
networking.hostName = "reykjavik";
boot.loader.systemd-boot.enable = true;
# - Modules ------------------------------------
samfelag.modules = {
# user.name = "marc";
bluetooth.enable = true;
editors.emacs.enable = true;
};
# - Profiles -----------------------------------
samfelag.profiles = {
desktop = {
enable = true;
laptop = true;
};
gaming.enable = true;
};
system.stateVersion = "22.05";
}

View File

@@ -1,9 +0,0 @@
{ ... }:
{
imports = [
./editors
./bluetooth.nix
./tailscale.nix
];
}

View File

@@ -1,7 +0,0 @@
{ ... }:
{
imports = [
./emacs.nix
];
}

View File

@@ -1,16 +0,0 @@
{ config, lib, pkgs, self, ... }:
let
cfg = config.samfelag.modules.tailscale;
in
{
options.samfelag.modules.tailscale = {
enable = lib.mkEnableOption "tailscale";
};
config = lib.mkIf cfg.enable {
services.tailscale = {
enable = true;
};
};
}

View File

@@ -1,9 +0,0 @@
{ ... }:
{
imports = [
./common.nix
./desktop.nix
./gaming.nix
];
}

View File

@@ -1,77 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.profiles.desktop;
in
{
options.samfelag.profiles.desktop = {
enable = mkEnableOption "desktop profile";
laptop = mkOption {
description = "Enable features for a laptop (trackpad, battery, etc...)";
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
# - Packages ---------------------------------
environment.systemPackages = with pkgs; [
pamixer
i3lock-blur
];
samfelag.modules.app.alacritty.enable = true;
# - Audio ------------------------------------
sound.enable = true;
hardware = {
pulseaudio = {
enable = true;
support32Bit = true;
package = pkgs.pulseaudioFull;
};
};
# - Window + Display Manager -----------------
environment.pathsToLink = [ "/libexec" ];
services.xserver = {
enable = true;
libinput = mkIf cfg.laptop {
enable = true;
touchpad.tapping = true;
};
desktopManager = {
xterm.enable = false;
};
displayManager = {
defaultSession = "none+i3";
lightdm = {
enable = true;
greeters.mini = {
enable = true;
user = "marc";
extraConfig = ''
[greeter]
show-sys-info = true
'';
};
};
};
windowManager.i3.enable = true;
};
};
}