Compare commits

..

4 Commits

Author SHA1 Message Date
marc
890b05d352 Unified home and system modules! 2022-11-19 11:58:21 +01:00
marc
cfcc374a69 Working checkpoint towards unified modules 2022-11-16 23:51:57 +01:00
marc
882c04a6bf Partial way to unifying nixos and home-manager modules 2022-11-16 20:28:32 +01:00
marc
5c609ddd42 Added custom lib (stolen from hlissner's dotifles) 2022-11-14 21:19:51 +01:00
55 changed files with 636 additions and 669 deletions

View File

@@ -1,90 +1,72 @@
* Installing
** Fresh system (nixos USB drive)
1. Open a nix-shell with git:
#+BEGIN_SRC bash
nix-shell -p git
#+END_SRC
2. Clone the flake
#+BEGIN_SRC bash
git clone https://git.lajuntament.space/marc/samfelag.git
#+END_SRC
3. Partition the disk
1. Locate the disk
#+BEGIN_SRC bash
lsblk
#+END_SRC
2. Create a GPT partition table
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mklabel gpt
#+END_SRC
3. Create the root partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart primary 512MB -8GB
#+END_SRC
4. Create the swap partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart primary linux-swap -8GB 100%
#+END_SRC
5. Create the boot partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB
sudo parted /dev/nvme0n1 -- set 3 esp on
#+END_SRC
4. Format the partitions
1. Root partition
#+BEGIN_SRC bash
sudo mkfs.ext4 -L nixos /dev/nvme0n1p1
#+END_SRC
2. Swap partition
#+BEGIN_SRC bash
sudo mkswap -L swap /dev/nvme0n1p2
#+END_SRC
3. Boot partition
#+BEGIN_SRC bash
sudo mkfs.fat -F 32 -n BOOT /dev/nvme0n1p3
#+END_SRC
5. Mount the filesystems
1. Root partition
#+BEGIN_SRC bash
sudo mount /dev/disk/by-label/nixos /mnt
#+END_SRC
2. Boot partition
#+BEGIN_SRC bash
sudo mkdir -p /mnt/boot
sudo mount /dev/disk/by-label/BOOT /mnt/boot
#+END_SRC
3. Swap partition (if needed)
#+BEGIN_SRC bash
sudo swapon /dev/disk/by-label/swap
#+END_SRC
6. Create the host nix configuration
If the host is not present under system/hosts, create a new folder for the host.
Generate the hardware configuration file, you can use nixos-generate-config as a base:
#+BEGIN_SRC bash
nixos-generate-config --dir <<host directory>> --no-filesystems
#+END_SRC
7. Install nixos!
#+BEGIN_SRC bash
sudo nixos-install --impure --root /mnt --flake .#reykjavik
#+END_SRC
8. Set up the user
You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user:
#+BEGIN_SRC bash

View File

@@ -22,6 +22,7 @@
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
(setq doom-font (font-spec :family "Iosevka" :size 15))
(setq doom-unicode-font (font-spec :family "Iosevka Nerd Font" :size 15))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
@@ -105,47 +106,39 @@
(setq org-directory "~/org/")
(use-package org-roam
:ensure t
:init
(setq org-roam-v2-ack t)
:custom
(org-roam-directory "~/org-roam")
(org-roam-capture-templates
'(("d" "default" plain "%?"
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("m" "màquina" plain (file "~/org-roam/templates/maquina.org")
:target (file "%<%Y%m%d%H%M%S>-${slug}.org")
:unnarrowed t)
("s" "software" plain (file "~/org-roam/templates/software.org")
:target (file "%<%Y%m%d%H%M%S>-${slug}.org")
:unnarrowed t)))
:config
(org-roam-setup))
(use-package! websocket
:after org-roam)
(use-package! org-roam-ui
:after org-roam ;; or :after org
;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have
;; a hookable mode anymore, you're advised to pick something yourself
;; if you don't care about startup time, use
;; :hook (after-init . org-roam-ui-mode)
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start nil))
;; -----------------------------------------------------------------------------
;; Lilypond
;; -----------------------------------------------------------------------------
(load-library "lilypond-mode")
(add-to-list 'auto-mode-alist '("\\.ly$" . LilyPond-mode))
; (use-package org-roam
; :ensure t
; :init
; (setq org-roam-v2-ack t)
; :custom
; (org-roam-directory "~/org-roam")
; (org-roam-capture-templates
; '(("d" "default" plain "%?"
; :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
; :unnarrowed t)
; ("m" "màquina" plain (file "~/org-roam/templates/maquina.org")
; :target (file "%<%Y%m%d%H%M%S>-${slug}.org")
; :unnarrowed t)
; ("s" "software" plain (file "~/org-roam/templates/software.org")
; :target (file "%<%Y%m%d%H%M%S>-${slug}.org")
; :unnarrowed t)))
; :config
; (org-roam-setup))
;
; (use-package! websocket
; :after org-roam)
;
; (use-package! org-roam-ui
; :after org-roam ;; or :after org
; ;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have
; ;; a hookable mode anymore, you're advised to pick something yourself
; ;; if you don't care about startup time, use
; ;; :hook (after-init . org-roam-ui-mode)
; :config
; (setq org-roam-ui-sync-theme t
; org-roam-ui-follow t
; org-roam-ui-update-on-save t
; org-roam-ui-open-on-start nil))
;; -----------------------------------------------------------------------------
;; Appearance - Prettify

View File

@@ -31,7 +31,7 @@
doom-dashboard ; a nifty splash screen for Emacs
;; doom-quit ; DOOM quit-message prompts when you quit Emacs
;;(emoji +unicode) ; 🙂
fill-column ; a `fill-column' indicator
;; fill-column ; a `fill-column' indicator
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra
;;indent-guides ; highlighted indent columns
@@ -149,7 +149,6 @@
;;ocaml ; an objective camel
(org
+journal
+roam2
+pretty) ; organize your plain life in plain text
php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more

View File

@@ -60,6 +60,6 @@
;; Org
;; Org-Roam UI
(unpin! org-roam)
(package! websocket)
(package! org-roam-ui :recipe (:host github :repo "org-roam/org-roam-ui" :files ("*.el" "out")))
; (unpin! org-roam)
; (package! websocket)
; (package! org-roam-ui :recipe (:host github :repo "org-roam/org-roam-ui" :files ("*.el" "out")))

17
flake.lock generated
View File

@@ -1,21 +1,5 @@
{
"nodes": {
"doom-emacs": {
"flake": false,
"locked": {
"lastModified": 1667229496,
"narHash": "sha256-SURAFrtblyvkflQz1cEQogfo31UzSvKd+UOgczUyJ8k=",
"owner": "doomemacs",
"repo": "doomemacs",
"rev": "9d4d5b756a8598c4b5c842e9f1f33148af2af8fd",
"type": "github"
},
"original": {
"owner": "doomemacs",
"repo": "doomemacs",
"type": "github"
}
},
"emacs-overlay": {
"inputs": {
"flake-utils": "flake-utils",
@@ -103,7 +87,6 @@
},
"root": {
"inputs": {
"doom-emacs": "doom-emacs",
"emacs-overlay": "emacs-overlay",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_2"

View File

@@ -20,57 +20,44 @@
config.allowUnfree = true;
overlays = import ./overlays;
};
lib = nixpkgs.lib;
lib = nixpkgs.lib.extend
(self: super: { my = import ./lib { inherit pkgs inputs; lib = self; }; });
in {
nixosConfigurations = {
# - 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
];
};
}
];
};
# - Reykjavik ----------------------------
reykjavik = lib.nixosSystem {
inherit system;
inherit pkgs;
specialArgs = { inherit inputs; };
specialArgs = { inherit lib inputs system; };
modules = [
./system/modules
./system/profiles
./system/hosts/reykjavik
./hosts/reykjavik
home-manager.nixosModules.home-manager {
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.marc = {
imports = [
./home/modules
./home/profiles
./home/hosts/reykjavik.nix
];
};
{
imports =
[ inputs.home-manager.nixosModules.home-manager ]
# All my personal modules
++ (lib.my.mapModulesRec' (toString ./modules) import);
}
];
};
# - Kopavogur ----------------------------
kopavogur = lib.nixosSystem {
inherit system;
inherit pkgs;
specialArgs = { inherit lib inputs system; };
modules = [
./hosts/kopavogur
{
imports =
[ inputs.home-manager.nixosModules.home-manager ]
# All my personal modules
++ (lib.my.mapModulesRec' (toString ./modules) import);
}
];

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,51 +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;
};
app.alacritty.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;
};
}

28
lib/attrs.nix Normal file
View File

@@ -0,0 +1,28 @@
{ lib, ... }:
with builtins;
with lib;
rec {
# attrsToList
attrsToList = attrs:
mapAttrsToList (name: value: { inherit name value; }) attrs;
# mapFilterAttrs ::
# (name -> value -> bool)
# (name -> value -> { name = any; value = any; })
# attrs
# Generate an attribute set by mapping a function (f) to it and then filter
# by the predicate (pred)
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
# Generate an attribute set by mapping a function over a list of values.
genAttrs' = values: f: listToAttrs (map f values);
# anyAttrs :: (name -> value -> bool) attrs
anyAttrs = pred: attrs:
any (attr: pred attr.name attr.value) (attrsToList attrs);
# countAttrs :: (name -> value -> bool) attrs
countAttrs = pred: attrs:
count (attr: pred attr.name attr.value) (attrsToList attrs);
}

31
lib/default.nix Normal file
View File

@@ -0,0 +1,31 @@
{ inputs, lib, pkgs, ... }:
let
inherit (lib) makeExtensible attrValues foldr;
inherit (modules) mapModules;
# We define modules, so we can use mapModules
modules = import ./modules.nix {
inherit lib;
self.attrs = import ./attrs.nix { inherit lib; self = {}; };
};
# mylib = {
# "attrs" = import "attrs.nix" { selg lib pkgs inputs };
# "options" = import "options.nix" { selg lib pkgs inputs };
# ...
# "extend": <<lambda>>; # from makeExtensible
# "__unfix__": <<lambda>>; # from makeExtensible
# }
mylib = makeExtensible (self:
with self; mapModules ./.
(file: import file { inherit self lib pkgs inputs; }));
in
# We have
# (attrValues super) = [ (import "attrs.nix" {...}) (import "options.nix" {...}) ... ]
# And thus
# mylib.extend(...) = (import "attrs.nix" {...}) // (import "options.nix" {...}) // ...
# Which is what we want, default.nix returns all modules merged (and extensible)
mylib.extend
(self: super:
foldr (a: b: a // b) {} (attrValues super))

65
lib/modules.nix Normal file
View File

@@ -0,0 +1,65 @@
{ self, lib, ... }:
let
inherit (builtins) attrValues readDir pathExists concatLists;
inherit (lib) id mapAttrsToList filterAttrs hasPrefix hasSuffix nameValuePair removeSuffix;
inherit (self.attrs) mapFilterAttrs;
in
rec {
# Returns an attribute set with the keys being the files in a directory
# and the values a function applied to their paths
# Only *.nix files and directories with a default.nix file are considered.
# The ".nix" suffix is removed from the keys of the attribute set.
mapModules = dir: fn:
mapFilterAttrs
(n: v:
v != null &&
!(hasPrefix "_" n))
(n: v:
let path = "${toString dir}/${n}"; in
if v == "directory" && pathExists "${path}/default.nix"
then nameValuePair n (fn path)
else if v == "regular" &&
n != "default.nix" &&
hasSuffix ".nix" n
then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
# Like mapModules above, but it just returns the values
# (map the function fn over the files in a directory)
mapModules' = dir: fn:
attrValues (mapModules dir fn);
# Like mapModules, but recursive. That is, if there is a directory, the
# value will be another attribute set with its contents as keys and the funcion
# applied to them as values.
mapModulesRec = dir: fn:
mapFilterAttrs
(n: v:
v != null &&
!(hasPrefix "_" n))
(n: v:
let path = "${toString dir}/${n}"; in
if v == "directory"
then nameValuePair n (mapModulesRec path fn)
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null)
(readDir dir);
# Like mapModulesRec but flattened and only the values. That is, it returns a list
# with fn applied to all *.nix files within the directory and subdirectories
# excluding default.nix files.
mapModulesRec' = dir: fn:
let
dirs =
mapAttrsToList
(k: _: "${dir}/${k}")
(filterAttrs
(n: v: v == "directory" && !(hasPrefix "_" n))
(readDir dir));
files = attrValues (mapModules dir id);
paths = files ++ concatLists (map (d: mapModulesRec' d id) dirs);
in map fn paths;
}

18
lib/options.nix Normal file
View File

@@ -0,0 +1,18 @@
{ lib, ... }:
let
inherit (lib) mkOption types;
in
rec {
mkOpt = type: default:
mkOption { inherit type default; };
mkOpt' = type: default: description:
mkOption { inherit type default description; };
mkBoolOpt = default: mkOption {
inherit default;
type = types.bool;
example = true;
};
}

View File

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

View File

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

View File

@@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.app.spotify;
in
{
options.samfelag.modules.app.spotify = {
enable = mkEnableOption "spotify";
enable = lib.mkEnableOption "spotify";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
config = lib.mkIf cfg.enable {
hm.home.packages = with pkgs; [
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, ... }:
{
# - Nix ----------------------------------------
system.stateVersion = "22.05";
nix = {
package = pkgs.nixFlakes;
@@ -39,12 +46,17 @@
vim
];
# - Other --------------------------------------
# - Modules ------------------------------------
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

@@ -18,12 +18,24 @@ let
});
system_mode = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown";
bg_colour = "#808F85";
paths = {
wallpapers = ../../data/wallpapers;
};
in {
options.samfelag.modules.desktop.i3 = {
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 {
type = cmdModule;
};
@@ -42,15 +54,45 @@ in {
# - Dependencies -----------------------------
home.packages = with pkgs; [
environment.systemPackages = with pkgs; [
(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 ----------------------------
xsession.windowManager.i3 = {
hm.xsession.windowManager.i3 = {
enable = true;
config = {
@@ -64,7 +106,7 @@ in {
focus.followMouse = false;
bars = [ ];
bars = [ ];
window = {
border = 1;
@@ -76,11 +118,10 @@ in {
# outer = 5;
# };
startup = [
startup = [
{ command = "i3-msg workspace 1"; }
{ 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 = {
@@ -99,7 +140,7 @@ in {
"Escape" = "mode \"default\"";
};
"${system_mode}" = {
"${system_mode}" = {
"l" = "exec --no-startup-id ${cfg.locker.command}, mode \"default\"";
"e" = "exec --no-startup-id i3-msg exit, mode \"default\"";
"s" = "exec --no-startup-id ${cfg.locker.command} && systemctl suspend, mode \"default\"";
@@ -163,18 +204,18 @@ in {
# - Media ------------------------------
# Pulse Audio controls
"XF86AudioRaiseVolume" = "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+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%";
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
# Pulse Audio controls
"XF86AudioRaiseVolume" = "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+XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%";
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
# Media player controls
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioPause" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
# Media player controls
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioPause" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioStop" = "exec playerctl stop";
# - Workspaces -------------------------

View File

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

@@ -33,7 +33,8 @@ in {
environment.systemPackages = with pkgs; [
## Emacs itself
binutils
emacs
((emacsPackagesFor emacsNativeComp).emacsWithPackages
(epkgs: [ epkgs.vterm ]))
# emacsPgtkGcc
## Doom dependencies
@@ -47,7 +48,13 @@ in {
pinentry_emacs
zstd
# ## Modules deps
## Modules deps
# :tools vterm
gcc
gnumake
libtool
cmake
# # :lang cc
# ccls
# cmake
@@ -74,10 +81,6 @@ in {
# sqlite
# # :tools direnv
# direnv
# # :tools vterm
# gcc
# gnumake
# libtool
# Fonts
emacs-all-the-icons-fonts
@@ -89,20 +92,9 @@ in {
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 {
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;
home-manager.users.marc.xdg.configFile."doom".source = ../../config/doom;
system.userActivationScripts = {
installDoomEmacs = ''

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, ... }:
let
cfg = config.samfelag.profiles.gaming;
cfg = config.samfelag.modules.gaming.steam;
in
{
options.samfelag.profiles.gaming = {
enable = lib.mkEnableOption "gaming profile";
options.samfelag.modules.gaming.steam = {
enable = lib.mkEnableOption "steam";
};
config = lib.mkIf cfg.enable {
programs.steam = {
enable = true;

57
modules/options.nix Normal file
View File

@@ -0,0 +1,57 @@
{ config, options, lib, home-manager, ... }:
with lib;
with lib.my;
{
options = with types; {
user = mkOpt attrs {};
hm = mkOpt attrs {};
env = mkOption {
# env = { PATH = ["$PATH" ./test]; TEST = "test"; }
type = attrsOf (oneOf [ str path (listOf (either str path)) ]);
# env = { PATH = "$PATH:./test"; TEST = "test"; }
apply = mapAttrs
(n: v: if isList v
then concatMapStringsSep ":" (x: toString x) v
else (toString v));
default = {};
description = "Set environment variables that will be joined by a colon";
};
};
config = {
user = {
description = "The primary user account";
extraGroups = [ "wheel" ];
isNormalUser = true;
home = "/home/${config.user.name}";
group = "users";
uid = 1000;
};
users.users.${config.user.name} = mkAliasDefinitions options.user;
nix.settings = let users = [ "root" config.user.name ]; in {
trusted-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" ];
environment.extraInit =
concatStringsSep "\n"
(mapAttrsToList (n: v: "export ${n}=\"${v}\"") config.env);
};
}

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, ... }:
with lib;
let
cfg = config.samfelag.modules.shell.zsh;
in
{
options.samfelag.modules.shell.zsh = {
enable = mkEnableOption "zsh configuration";
enable = lib.mkEnableOption "zsh";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
zsh
zsh-powerlevel10k
(nerdfonts.override { fonts = [ "Iosevka" ]; })
];
programs.zsh = {
hm.programs.zsh = {
enable = true;
dotDir = ".config/zsh";
@@ -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, ... }:
let
cfg = config.samfelag.modules.bluetooth;
cfg = config.samfelag.modules.system.bluetooth;
in
{
options.samfelag.modules.bluetooth = {
options.samfelag.modules.system.bluetooth = {
enable = lib.mkEnableOption "bluetooth";
};
config = lib.mkIf cfg.enable {
hardware.bluetooth.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,36 +0,0 @@
{ config, pkgs, lib, ... }:
{
imports = [
./hardware.nix
./nvidia.nix
];
# - Basic --------------------------------------
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,10 +0,0 @@
{ ... }:
{
imports = [
./editors
./bluetooth.nix
./tailscale.nix
./user.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,36 +0,0 @@
{ config, lib, pkgs, self, ... }:
let
cfg = config.samfelag.modules.user;
in
{
options.samfelag.modules.user = {
name = lib.mkOption {
type = lib.types.str;
default = "marc";
description = ''
Specifies the user name
'';
};
};
config = lib.mkMerge [
{
programs.zsh.enable = true;
users = {
defaultUserShell = pkgs.zsh;
users."${cfg.name}" = with cfg; {
description = "Marc Sastre Rienitz";
isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ];
};
# Do not allow users to be added or modified except through Nix configuration.
# mutableUsers = false;
};
nix.settings.trusted-users = [ "${cfg.name}" ];
}
];
}

View File

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

View File

@@ -1,75 +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
];
# - 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;
};
};
}