Skip to content

Commit

Permalink
Large refactoring and organisation of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Mar 7, 2024
1 parent 959c513 commit 2e00c64
Show file tree
Hide file tree
Showing 25 changed files with 284 additions and 348 deletions.
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
...
}: let
inherit (self) outputs;
specialArgs = {inherit inputs outputs;};
user = "joonas";
specialArgs = {inherit inputs outputs user;};
in {
nixosModules = import ./modules;
homeManagerModules = import ./home-modules;
Expand Down
38 changes: 5 additions & 33 deletions home-modules/common.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
{
pkgs,
user,
...
}: {
home.stateVersion = "23.11";
programs.home-manager.enable = true;
dconf.enable = true;
nixpkgs.config.allowUnfree = true;
systemd.user.startServices = "sd-switch";
programs.home-manager.enable = true;

# temp fix while sourcehut is down
manual.manpages.enable = false;

# this needs to be done separately for home manager
nixpkgs = {
config.allowUnfree = true;
overlays = import ../overlays {inherit pkgs;};
};

xdg = {
enable = true;
userDirs = {
enable = true;
desktop = "/home/${user}";
templates = "/home/${user}";
publicShare = "/home/${user}";
documents = "/home/${user}/documents";
download = "/home/${user}/downloads";
music = "/home/${user}/music";
pictures = "/home/${user}/pictures";
videos = "/home/${user}/videos";
};

desktopEntries."transmission-magnet" = {
name = "Transmission add torrent";
exec = ''add-torrent %u'';
mimeType = ["x-scheme-handler/magnet"];
};
services = {
easyeffects.enable = true;
udiskie.enable = true;
};
}
65 changes: 48 additions & 17 deletions home-modules/default.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
# Reusable Home-manager modules
{
rec {
polybar = import ./polybar;
xmonad = import ./xmonad;
common = import ./common.nix;
neovim = import ./neovim.nix;
zsh = import ./zsh.nix;
xresources = import ./xresources.nix;
wezterm = import ./wezterm.nix;
xinitrc = import ./xinitrc.nix;
dark-mode = import ./dark-mode.nix;
discord = import ./discord.nix;
dunst = import ./dunst.nix;
picom = import ./picom.nix;
firefox = import ./firefox.nix;
flameshot = import ./flameshot.nix;
git = import ./git.nix;
ssh-personal = import ./ssh-personal.nix;
ssh-work = import ./ssh-work.nix;
gtk = import ./gtk.nix;
hidpi = import ./hidpi.nix;
rofi = import ./rofi.nix;
discord = import ./discord.nix;
imv = import ./imv.nix;
mpv = import ./mpv.nix;
neovim = import ./neovim.nix;
picom = import ./picom.nix;
redshift = import ./redshift.nix;
flameshot = import ./flameshot.nix;
rofi = import ./rofi.nix;
ssh-personal = import ./ssh-personal.nix;
ssh-work = import ./ssh-work.nix;
starship = import ./starship.nix;
imv = import ./imv.nix;
wezterm = import ./wezterm.nix;
xdg = import ./xdg.nix;
xinitrc = import ./xinitrc.nix;
xresources = import ./xresources.nix;
yazi = import ./yazi.nix;
gtk = import ./gtk.nix;
xmonad = import ./xmonad;
polybar = import ./polybar;
mpv = import ./mpv.nix;
zsh = import ./zsh.nix;

default-modules = [
polybar
xmonad
common
dark-mode
discord
dunst
firefox
flameshot
git
gtk
imv
mpv
neovim
picom
redshift
rofi
ssh-personal
ssh-work
starship
wezterm
xdg
xinitrc
xresources
yazi
zsh
];
}
9 changes: 9 additions & 0 deletions home-modules/firefox.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
programs.firefox = {
enable = true;
policies = {
DownloadDirectory = "\${home}/downloads";
OfferToSaveLogins = false;
};
};
}
2 changes: 0 additions & 2 deletions home-modules/flameshot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
General = {
disabledTrayIcon = true;
showStartupLaunchMessage = false;
# breaks clipboard..
# useJpgForClipboard = true;
checkForUpdates = false;
savePath = "/home/${user}/pictures/screenshots";
};
Expand Down
22 changes: 22 additions & 0 deletions home-modules/xdg.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{user, ...}: {
xdg = {
enable = true;
userDirs = {
enable = true;
desktop = "/home/${user}";
templates = "/home/${user}";
publicShare = "/home/${user}";
documents = "/home/${user}/documents";
download = "/home/${user}/downloads";
music = "/home/${user}/music";
pictures = "/home/${user}/pictures";
videos = "/home/${user}/videos";
};

desktopEntries."transmission-magnet" = {
name = "Transmission add torrent";
exec = ''add-torrent %u'';
mimeType = ["x-scheme-handler/magnet"];
};
};
}
9 changes: 9 additions & 0 deletions home-modules/xmonad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@
enableContribAndExtras = true;
config = ./xmonad.hs;
};

home.packages = [
(pkgs.haskellPackages.ghcWithPackages (p:
with p; [
xmobar
xmonad
xmonad-contrib
]))
];
}
17 changes: 6 additions & 11 deletions hosts/hetzner/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
lib,
inputs,
outputs,
config,
pkgs,
modulesPath,
...
}: let
user = "joonas";
in {
}: {
imports = lib.flatten [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
(with outputs.nixosModules; [
(common {inherit user pkgs outputs;})
(syncthing {inherit user config lib;})
(ssh-access {inherit user;})
(docker {inherit user;})
common
syncthing
ssh-access
docker
nginx
])
inputs.disko.nixosModules.disko
Expand All @@ -29,8 +26,6 @@ in {
boot = {
initrd.availableKernelModules = ["ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod"];
loader.grub = {
# no need to set devices, disko will add all devices that have a EF02 partition to the list already
# devices = [ ];
efiSupport = true;
efiInstallAsRemovable = true;
};
Expand All @@ -49,8 +44,8 @@ in {

environment.systemPackages = with pkgs; [
neovim
wget
git
busybox
];

services.syncthing = {
Expand Down
9 changes: 3 additions & 6 deletions hosts/unikie/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
pkgs,
lib,
outputs,
config,
...
}: let
user = "joonas";
in {
}: {
imports = lib.flatten [
(with outputs.nixosModules; [
(common {inherit user pkgs outputs;})
(syncthing {inherit user config lib;})
common
syncthing
laptop
bluetooth
gui
Expand Down
31 changes: 7 additions & 24 deletions hosts/x1/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,29 @@
inputs,
outputs,
lib,
config,
pkgs,
...
}: let
user = "joonas";
system = "x86_64-linux";
in {
}: {
imports = lib.flatten [
(with outputs.nixosModules; [
(common {inherit user pkgs outputs;})
(syncthing {inherit user config lib;})
(docker {inherit user;})
common
syncthing
docker
bootloader
laptop
bluetooth
gui
work-vpn
keyd
(bin {inherit inputs system;})
bin
])
(with inputs.nixos-hardware.nixosModules; [
lenovo-thinkpad-x1-11th-gen
])
(import ./home.nix {inherit inputs outputs pkgs user lib;})
./hardware-configuration.nix
./home.nix
];

boot = {
# force S3 sleep mode
kernelParams = ["mem_sleep_default=deep"];

loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
};

networking = {
hostName = "x1";
hostId = "c08d7d71";
Expand All @@ -55,10 +42,6 @@ in {
};

tailscale.enable = true;

# fingerprint scanner daemon
# to enroll a finger, use sudo fprintd-enroll $USER
fprintd.enable = false;
};

environment.systemPackages = lib.flatten [
Expand Down
47 changes: 13 additions & 34 deletions hosts/x1/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,26 @@
outputs,
pkgs,
user,
lib,
...
}: {
imports = [
inputs.home-manager.nixosModules.home-manager
];

home-manager.users."${user}" = {
imports = pkgs.lib.flatten [
(with outputs.homeManagerModules; [
(common {inherit pkgs user;})
xresources
(neovim {inherit pkgs user;})
zsh
wezterm
xinitrc
picom
git
ssh-personal
ssh-work
dunst
rofi
discord
redshift
(flameshot {inherit user;})
starship
imv
yazi
gtk
xmonad
polybar
mpv
])
inputs.nixvim.homeManagerModules.nixvim
inputs.nix-index-database.hmModules.nix-index
];
home-manager = {
extraSpecialArgs = {inherit user;};

services = {
easyeffects.enable = true;
batsignal.enable = true;
udiskie.enable = true;
users."${user}" = {
imports = pkgs.lib.flatten [
(with outputs.homeManagerModules; [
default-modules
hidpi
])
inputs.nixvim.homeManagerModules.nixvim
inputs.nix-index-database.hmModules.nix-index
];

services.batsignal.enable = true;
};
};
}
Loading

0 comments on commit 2e00c64

Please sign in to comment.