Initial commit

This commit is contained in:
marc
2022-10-02 20:33:40 +02:00
commit a1d321316c
30 changed files with 2492 additions and 0 deletions

0
README.org Normal file
View File

View File

@@ -0,0 +1,4 @@
font:
normal:
family: Iosevka Nerd Font
style: Regular

View File

@@ -0,0 +1,12 @@
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
# editor and vim
[[ -n "$(command -v nvim)" ]] && {
export EDITOR='nvim'
export VISUAL='nvim'
} || {
export EDITOR="vim"
export VISUAL="vim"
}

View File

@@ -0,0 +1,7 @@
[[ -x "$(command -v exa)" ]] && {
alias ll="exa --group-directories-first --color=auto --git -la"
} || {
alias ll="ls -alh --color=always --group-directories-first"
}
[[ -x "$(command -v bat)" ]] && alias cat="bat"

View File

@@ -0,0 +1,16 @@
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=$HOME/.cache/zsh/history
mkdir -p $(dirname "$HISTFILE")
# https://www.commandlinux.com/man-page/man1/zshoptions.1.html
setopt HIST_FCNTL_LOCK # Better file lock call with histfile
setopt HIST_IGNORE_DUPS # Ignore command if duplicate of prev event
setopt HIST_IGNORE_SPACE # Ignore command if starts with a space
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first
setopt SHARE_HISTORY # Share history between zsh sessions
unsetopt EXTENDED_HISTORY # Make sure no timestamps in histfile
# Ignore case completion for zsh
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'

1723
config/.config/zsh/.p10k.zsh Normal file

File diff suppressed because it is too large Load Diff

49
flake.lock generated Normal file
View File

@@ -0,0 +1,49 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1656169755,
"narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "4a3d01fb53f52ac83194081272795aa4612c2381",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-22.05",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1664594436,
"narHash": "sha256-YHowMADGzdi7fKnGlg47qe0PIljq+11VqLarmXDuKxQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9cac45850280978a21a3eb67b15a18f34cbffa2d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

52
flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "System configuration for all machines in samfélag";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
home-manager = {
url = "github:nix-community/home-manager/release-22.05";
# Use packages from nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in {
nixosConfigurations = {
# - Kopavogur ----------------------------
kopavogur = lib.nixosSystem {
inherit system;
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
];
};
}
];
};
};
};
}

11
home/hosts/kopavogur.nix Normal file
View File

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

Binary file not shown.

View File

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

View File

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

10
home/modules/default.nix Normal file
View File

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

View File

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

132
home/modules/desktop/i3.nix Normal file
View File

@@ -0,0 +1,132 @@
{ config, lib, pkgs, ... }:
let
cfg = config.samfelag.modules.desktop.i3;
mod = "Mod4";
cmdModule = lib.types.submodule ({ ... }: {
options = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
};
command = lib.mkOption {
type = lib.types.str;
example = "${pkgs.rofi}/bin/rofi rofi -show run";
};
};
});
in {
options.samfelag.modules.desktop.i3 = {
enable = lib.mkEnableOption "i3 window manager";
launcher = lib.mkOption {
type = cmdModule;
};
terminal = lib.mkOption {
type = cmdModule;
};
browser = lib.mkOption {
type = cmdModule;
};
};
config = lib.mkIf cfg.enable {
# - Dependencies -----------------------------
home.packages = with pkgs; [
(nerdfonts.override { fonts = [ "Iosevka" ]; })
];
# - Configuration ----------------------------
xsession.windowManager.i3 = {
enable = true;
config = {
modifier = mod;
fonts = {
names = ["DejaVu Sans Mono" "Iosevka Nerd Font"];
style = "regular";
size = 12.0;
};
focus.followMouse = false;
keybindings = {
"${mod}+q" = "kill";
# Focus
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
# Move
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
# split orientation
"${mod}+z" = "split h;exec notify-send 'tile horizontally'";
"${mod}+v" = "split v;exec notify-send 'tile vertically'";
# enter fullscreen mode for the focused container
"${mod}+f" = "fullscreen toggle";
# change container layout (stacked, tabbed, toggle split)
"${mod}+s" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+e" = "layout toggle split";
# toggle tiling / floating
"${mod}+Shift+space" = "floating toggle";
# focus the parent container
"${mod}+a" = "focus parent";
# - Workspaces -------------------------
"${mod}+1" = "workspace 1";
"${mod}+2" = "workspace 2";
"${mod}+3" = "workspace 3";
"${mod}+4" = "workspace 4";
"${mod}+5" = "workspace 5";
"${mod}+6" = "workspace 6";
"${mod}+7" = "workspace 7";
"${mod}+8" = "workspace 8";
"${mod}+9" = "workspace 9";
"${mod}+0" = "workspace 0";
"${mod}+Shift+1" = "move container to workspace 1; workspace 1";
"${mod}+Shift+2" = "move container to workspace 2; workspace 2";
"${mod}+Shift+3" = "move container to workspace 3; workspace 3";
"${mod}+Shift+4" = "move container to workspace 4; workspace 4";
"${mod}+Shift+5" = "move container to workspace 5; workspace 5";
"${mod}+Shift+6" = "move container to workspace 6; workspace 6";
"${mod}+Shift+7" = "move container to workspace 7; workspace 7";
"${mod}+Shift+8" = "move container to workspace 8; workspace 8";
"${mod}+Shift+9" = "move container to workspace 9; workspace 9";
"${mod}+Shift+0" = "move container to workspace 0; workspace 0";
}
// (if cfg.terminal.enable then {
"${mod}+Return" = "exec ${cfg.terminal.command}";
} else {})
// (if cfg.launcher.enable then {
"${mod}+space" = "exec ${cfg.launcher.command}";
} else {});
};
};
};
}

View File

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

24
home/modules/dev/git.nix Normal file
View File

@@ -0,0 +1,24 @@
{ 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

@@ -0,0 +1,30 @@
{ 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

@@ -0,0 +1,70 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.samfelag.modules.shell.zsh;
in
{
options.samfelag.modules.shell.zsh = {
enable = mkEnableOption "zsh configuration";
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
zsh
zsh-powerlevel10k
(nerdfonts.override { fonts = [ "Iosevka" ]; })
];
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
enableAutosuggestions = true;
enableCompletion = true;
enableSyntaxHighlighting = true;
initExtra = ''
# Source generic (bash) configuration
if [ -d $HOME/.config/shell/sh ]; then
for rc in $HOME/.config/shell/sh/*.sh; do
emulate bash -c ". $rc"
done
fi
# Source zsh specific configuration
if [[ -d $HOME/.config/shell/zsh ]]; then
for rc in $HOME/.config/shell/zsh/*.zsh; do
source $rc
done
fi
'';
initExtraBeforeCompInit = ''
# p10k instant prompt
P10K_INSTANT_PROMPT="$XDG_CACHE_HOME/p10k-instant-prompt-''${(%):-%n}.zsh"
[[ ! -r "$P10K_INSTANT_PROMPT" ]] || source "$P10K_INSTANT_PROMPT"
'';
oh-my-zsh = {
enable = true;
plugins = [
"git"
# "zsh-vi-mode"
];
};
plugins = [
{
file = "powerlevel10k.zsh-theme";
name = "powerlevel10k";
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k";
}
];
};
xdg.configFile."zsh/.p10k.zsh".source = ../../../config/.config/zsh/.p10k.zsh;
};
}

17
home/profiles/common.nix Normal file
View File

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

View File

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

44
home/profiles/desktop.nix Normal file
View File

@@ -0,0 +1,44 @@
{ 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";
};
app.alacritty.enable = true;
};
home.packages = with pkgs; [
rofi
firefox
brightnessctl
playerctl
feh
] ++ optionals cfg.laptop laptopPkgs;
};
}

View File

@@ -0,0 +1,28 @@
{ 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

@@ -0,0 +1,40 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
availableKernelModules = [ "uhci_hcd" "ehci_pci" "ata_piix" "ahci" "xhci_pci" "pata_jmicron" "firewire_ohci" "usbhid" "usb_storage" "sd_mod" "sr_mod" ];
kernelModules = [ ];
};
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ config.boot.kernelPackages.rtl88xxau-aircrack ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
};
};
swapDevices = [
{ device = "/dev/disk/by-label/swap"; }
];
networking = {
useDHCP = lib.mkDefault true;
interfaces = {
enp7s0.useDHCP = lib.mkDefault true;
wlp0s26f7u2.useDHCP = lib.mkDefault true;
};
};
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@@ -0,0 +1,2 @@
* Kopavogur
Ordinador (torre) de l'Ajuntament

View File

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

36
system/modules/user.nix Normal file
View File

@@ -0,0 +1,36 @@
{ 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

@@ -0,0 +1,46 @@
{ config, pkgs, lib, ... }:
{
# - Nix ----------------------------------------
nix = {
package = pkgs.nixFlakes;
extraOptions = lib.optionalString (config.nix.package == pkgs.nixFlakes)
"experimental-features = nix-command flakes";
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
# - Locale -------------------------------------
time.timeZone = "Europe/Madrid";
i18n.defaultLocale = "ca_ES.utf8";
console.keyMap = "es";
services.xserver = {
layout = "es";
xkbVariant = "cat";
};
# - Packages -----------------------------------
environment.pathsToLink = [ "/libexec" ];
environment.systemPackages = with pkgs; [
curl
git
pciutils
vim
];
# - Other --------------------------------------
networking.networkmanager.enable = true;
system.stateVersion = "22.05";
}

View File

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

View File

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