Use alejandra for formatting Nix files

This commit is contained in:
Oliver Davies 2024-02-13 21:33:32 +00:00
parent 7db4788e49
commit 7302dae7ec
17 changed files with 273 additions and 244 deletions

View file

@ -7,21 +7,28 @@
opdavies-nvim.url = "github:opdavies/opdavies.nvim"; opdavies-nvim.url = "github:opdavies/opdavies.nvim";
}; };
outputs = inputs@{ flake-parts, self, ... }: outputs = inputs @ {
let flake-parts,
self,
...
}: let
system = "x86_64-linux"; system = "x86_64-linux";
username = "opdavies"; username = "opdavies";
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
nixos-system = import ./system/nixos { inherit inputs pkgs self system username; }; nixos-system = import ./system/nixos {inherit inputs pkgs self system username;};
wsl-system = import ./system/wsl2 { inherit inputs pkgs self system username; }; wsl-system = import ./system/wsl2 {inherit inputs pkgs self system username;};
in in
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake {inherit inputs;} {
systems = [ "x86_64-linux" ]; systems = ["x86_64-linux"];
perSystem = { pkgs, self', ... }: { perSystem = {
formatter = pkgs.nixpkgs-fmt; pkgs,
self',
...
}: {
formatter = pkgs.alejandra;
}; };
flake = { flake = {

View file

@ -1,18 +1,20 @@
{ inputs, desktop ? false, hostname, pkgs, system }: {
inputs,
let desktop ? false,
hostname,
pkgs,
system,
}: let
pkgs-2311 = inputs.nixpkgs-2311.legacyPackages.${system}; pkgs-2311 = inputs.nixpkgs-2311.legacyPackages.${system};
configure-gtk = pkgs.writeTextFile { configure-gtk = pkgs.writeTextFile {
name = "configure-gtk"; name = "configure-gtk";
destination = "/bin/configure-gtk"; destination = "/bin/configure-gtk";
executable = true; executable = true;
text = text = let
let
schema = pkgs.gsettings-desktop-schemas; schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}"; datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in in ''
''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme 'Breeze Dark' gsettings set $gnome_schema gtk-theme 'Breeze Dark'
@ -20,8 +22,7 @@ let
}; };
username = "opdavies"; username = "opdavies";
in in {
{
nixpkgs = { nixpkgs = {
config = { config = {
allowUnfree = true; allowUnfree = true;
@ -81,7 +82,7 @@ in
windowManager.i3 = { windowManager.i3 = {
enable = true; enable = true;
extraPackages = with pkgs; [ i3status i3lock i3blocks ]; extraPackages = with pkgs; [i3status i3lock i3blocks];
}; };
}; };
@ -116,8 +117,8 @@ in
users.users.${username} = { users.users.${username} = {
isNormalUser = true; isNormalUser = true;
description = "Oliver Davies"; description = "Oliver Davies";
extraGroups = [ "docker" "networkmanager" "wheel" ]; extraGroups = ["docker" "networkmanager" "wheel"];
packages = with pkgs; [ ]; packages = with pkgs; [];
}; };
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
@ -133,7 +134,8 @@ in
xfce.thunar xfce.thunar
xfce.thunar-volman xfce.thunar-volman
xfce.tumbler xfce.tumbler
] ++ pkgs.lib.optionals desktop [ ]
++ pkgs.lib.optionals desktop [
acpi acpi
dunst dunst
libnotify libnotify
@ -182,7 +184,7 @@ in
fontconfig = { fontconfig = {
enable = true; enable = true;
defaultFonts = { defaultFonts = {
monospace = [ "JetBrainsMono Nerd Font Mono" ]; monospace = ["JetBrainsMono Nerd Font Mono"];
}; };
}; };
@ -214,24 +216,22 @@ in
settings = { settings = {
auto-optimise-store = true; auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ]; experimental-features = ["nix-command" "flakes"];
warn-dirty = false; warn-dirty = false;
}; };
}; };
# Make Caps lock work as an Escape key on press and Ctrl on hold. # Make Caps lock work as an Escape key on press and Ctrl on hold.
services.interception-tools = services.interception-tools = let
let
dfkConfig = pkgs.writeText "dual-function-keys.yaml" '' dfkConfig = pkgs.writeText "dual-function-keys.yaml" ''
MAPPINGS: MAPPINGS:
- KEY: KEY_CAPSLOCK - KEY: KEY_CAPSLOCK
TAP: KEY_ESC TAP: KEY_ESC
HOLD: KEY_LEFTCTRL HOLD: KEY_LEFTCTRL
''; '';
in in {
{
enable = true; enable = true;
plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ]; plugins = pkgs.lib.mkForce [pkgs.interception-tools-plugins.dual-function-keys];
udevmonConfig = '' udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE" - JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE: DEVICE:
@ -257,7 +257,7 @@ in
programs.firefox = { programs.firefox = {
enable = true; enable = true;
languagePacks = [ "en-GB" ]; languagePacks = ["en-GB"];
package = pkgs.firefox-devedition; package = pkgs.firefox-devedition;
preferences = { preferences = {
"intl.accept_languages" = "en-GB, en"; "intl.accept_languages" = "en-GB, en";

View file

@ -1,17 +1,22 @@
{ inputs, pkgs, self, system, username }: {
inputs,
{ desktop ? false, hostname }: pkgs,
self,
let system,
configuration = import ./configuration.nix { inherit desktop hostname inputs pkgs system; }; username,
}: {
desktop ? false,
hostname,
}: let
configuration = import ./configuration.nix {inherit desktop hostname inputs pkgs system;};
hardware-configuration = import ./hardware-configuration.nix; hardware-configuration = import ./hardware-configuration.nix;
in in
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
modules = [ modules = [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
{ {
home-manager = { home-manager = {
extraSpecialArgs = { inherit inputs desktop self username; }; extraSpecialArgs = {inherit inputs desktop self username;};
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users."${username}" = import ./home-manager; users."${username}" = import ./home-manager;
@ -21,4 +26,4 @@ inputs.nixpkgs.lib.nixosSystem {
configuration configuration
hardware-configuration hardware-configuration
]; ];
} }

View file

@ -1,14 +1,17 @@
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [(modulesPath + "/installer/scan/not-detected.nix")];
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules = ["xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod"];
[ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; boot.initrd.kernelModules = [];
boot.initrd.kernelModules = [ ]; boot.kernelModules = ["kvm-intel"];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelParams = ["i8042.reset"];
boot.kernelParams = [ "i8042.reset" ]; boot.extraModulePackages = [];
boot.extraModulePackages = [ ];
boot.kernelPackages = pkgs.linuxPackages_latest; boot.kernelPackages = pkgs.linuxPackages_latest;
hardware.enableAllFirmware = true; hardware.enableAllFirmware = true;
@ -23,8 +26,7 @@
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = swapDevices = [{device = "/dev/disk/by-label/swap";}];
[{ device = "/dev/disk/by-label/swap"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's
@ -39,5 +41,4 @@
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
hardware.cpu.intel.updateMicrocode = hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware; lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -1,14 +1,24 @@
{ config, desktop, inputs, pkgs, self, username, ... }:
let
desktop-config = import ./desktop.nix { inherit config inputs pkgs username; };
shared-config = import ../../shared/home-manager.nix { inherit inputs pkgs self username; };
shared-packages = import ../../shared/home-manager-packages.nix { inherit inputs pkgs; };
in
{ {
imports = if desktop then [ desktop-config shared-config ] else [ shared-config ]; config,
desktop,
inputs,
pkgs,
self,
username,
...
}: let
desktop-config = import ./desktop.nix {inherit config inputs pkgs username;};
shared-config = import ../../shared/home-manager.nix {inherit inputs pkgs self username;};
shared-packages = import ../../shared/home-manager-packages.nix {inherit inputs pkgs;};
in {
imports =
if desktop
then [desktop-config shared-config]
else [shared-config];
home.packages = shared-packages ++ pkgs.lib.optionals desktop [ home.packages =
shared-packages
++ pkgs.lib.optionals desktop [
pkgs.discord pkgs.discord
pkgs.gimp pkgs.gimp
pkgs.gscan2pdf pkgs.gscan2pdf

View file

@ -1,6 +1,9 @@
{ config, inputs, pkgs, username }:
{ {
config,
inputs,
pkgs,
username,
}: {
imports = [ imports = [
./modules/alacritty.nix ./modules/alacritty.nix
./modules/autorandr.nix ./modules/autorandr.nix

View file

@ -21,7 +21,7 @@
glyph_offset.y = 6; glyph_offset.y = 6;
}; };
shell = { program = "zsh"; }; shell = {program = "zsh";};
}; };
}; };
} }

View file

@ -1,6 +1,4 @@
{ username, ... }: {username, ...}: {
{
services.autorandr.enable = true; services.autorandr.enable = true;
xdg.configFile."autorandr/postswitch" = { xdg.configFile."autorandr/postswitch" = {
@ -15,12 +13,10 @@
programs.autorandr = { programs.autorandr = {
enable = true; enable = true;
profiles = profiles = let
let
laptop = "00ffffffffffff000daef21400000000161c0104a51f117802ee95a3544c99260f505400000001010101010101010101010101010101363680a0703820402e1e240035ad10000018000000fe004e3134304843472d4751320a20000000fe00434d4e0a202020202020202020000000fe004e3134304843472d4751320a2000bb"; laptop = "00ffffffffffff000daef21400000000161c0104a51f117802ee95a3544c99260f505400000001010101010101010101010101010101363680a0703820402e1e240035ad10000018000000fe004e3134304843472d4751320a20000000fe00434d4e0a202020202020202020000000fe004e3134304843472d4751320a2000bb";
monitor = "00ffffffffffff004c2d1710424e58432b1f0103803f24782ac8b5ad50449e250f5054bfef80714f810081c081809500a9c0b300010108e80030f2705a80b0588a0078682100001e000000fd00324b1e873c000a202020202020000000fc004c5532385235350a2020202020000000ff0048345a524130303132380a20200183020335f04961120313041f10605f2309070783010000e305c0006b030c002000b83c2000200167d85dc401788003e20f81e3060501023a801871382d40582c450078682100001e023a80d072382d40102c458078682100001e04740030f2705a80b0588a0078682100001e565e00a0a0a029503020350078682100001a000049"; monitor = "00ffffffffffff004c2d1710424e58432b1f0103803f24782ac8b5ad50449e250f5054bfef80714f810081c081809500a9c0b300010108e80030f2705a80b0588a0078682100001e000000fd00324b1e873c000a202020202020000000fc004c5532385235350a2020202020000000ff0048345a524130303132380a20200183020335f04961120313041f10605f2309070783010000e305c0006b030c002000b83c2000200167d85dc401788003e20f81e3060501023a801871382d40582c450078682100001e023a80d072382d40102c458078682100001e04740030f2705a80b0588a0078682100001e565e00a0a0a029503020350078682100001a000049";
in in {
{
laptop = { laptop = {
config.eDP-1 = { config.eDP-1 = {
enable = true; enable = true;

View file

@ -1,7 +1,6 @@
let let
baseUrl = "https://www.oliverdavies.uk"; baseUrl = "https://www.oliverdavies.uk";
in in {
{
services.espanso = { services.espanso = {
enable = true; enable = true;

View file

@ -1,19 +1,23 @@
{ config, inputs, self, username, pkgs, ... }:
let
modifier = "Mod4";
in
{ {
config,
inputs,
self,
username,
pkgs,
...
}: let
modifier = "Mod4";
in {
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
enable = true; enable = true;
config = { config = {
assigns = { assigns = {
"7" = [{ class = "vlc"; }]; "7" = [{class = "vlc";}];
"8" = [{ class = "0ad"; }]; "8" = [{class = "0ad";}];
"9" = [ "9" = [
{ class = "Slack"; } {class = "Slack";}
{ class = "discord"; } {class = "discord";}
]; ];
}; };
@ -81,7 +85,8 @@ in
''; '';
config = { config = {
bars = [{ bars = [
{
position = "bottom"; position = "bottom";
statusCommand = "${pkgs.i3status}/bin/i3status"; statusCommand = "${pkgs.i3status}/bin/i3status";
colors = { colors = {
@ -119,9 +124,10 @@ in
text = "#ffffff"; text = "#ffffff";
}; };
}; };
}]; }
];
fonts.names = [ "GeistMono" ]; fonts.names = ["GeistMono"];
gaps = { gaps = {
smartBorders = "on"; smartBorders = "on";

View file

@ -1,4 +1,8 @@
{ inputs, pkgs, ... }: {
inputs,
pkgs,
...
}:
with pkgs; [ with pkgs; [
awscli2 awscli2
bottom bottom

View file

@ -1,6 +1,9 @@
{ inputs, pkgs, username, self }:
{ {
inputs,
pkgs,
username,
self,
}: {
home.username = "${username}"; home.username = "${username}";
home.homeDirectory = "/home/${username}"; home.homeDirectory = "/home/${username}";
@ -9,7 +12,7 @@
programs.home-manager.enable = true; programs.home-manager.enable = true;
imports = [ imports = [
(import ./modules/neovim.nix { inherit inputs; }) (import ./modules/neovim.nix {inherit inputs;})
./modules/git.nix ./modules/git.nix
./modules/starship.nix ./modules/starship.nix
./modules/tmux.nix ./modules/tmux.nix
@ -38,7 +41,7 @@
nix-direnv.enable = true; nix-direnv.enable = true;
}; };
home.sessionPath = [ "$HOME/.config/bin" ]; home.sessionPath = ["$HOME/.config/bin"];
xdg.configFile."ripgrep/config".text = '' xdg.configFile."ripgrep/config".text = ''
--follow --follow

View file

@ -48,12 +48,10 @@
current-branch = "rev-parse --abbrev-ref HEAD"; current-branch = "rev-parse --abbrev-ref HEAD";
dc = "diff --color --word-diff --cached"; dc = "diff --color --word-diff --cached";
df = "diff --color --word-diff"; df = "diff --color --word-diff";
dup = dup = "!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -";
"!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -";
fixup = "commit --fixup"; fixup = "commit --fixup";
issues = "!gh issue list --web"; issues = "!gh issue list --web";
mup = mup = "!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -";
"!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -";
no-ff = "merge --no-ff"; no-ff = "merge --no-ff";
pl = "pull"; pl = "pull";
prune = "remote prune origin"; prune = "remote prune origin";
@ -65,12 +63,10 @@
repush = "!git pull --rebase && git push"; repush = "!git pull --rebase && git push";
ri = "rebase --interactive"; ri = "rebase --interactive";
rid = "!git rebase -i $(git merge-base develop HEAD)"; rid = "!git rebase -i $(git merge-base develop HEAD)";
rim = rim = "!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)";
"!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)";
rip = "!git rebase -i $(git merge-base production HEAD)"; rip = "!git rebase -i $(git merge-base production HEAD)";
ris = "!git rebase -i $(git merge-base staging HEAD)"; ris = "!git rebase -i $(git merge-base staging HEAD)";
riu = riu = "!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})";
"!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})";
rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%"; rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%";
sl = "log --oneline --decorate -20"; sl = "log --oneline --decorate -20";
sla = "log --oneline --decorate --graph --all -20"; sla = "log --oneline --decorate --graph --all -20";
@ -92,7 +88,7 @@
}; };
checkout.defaultRemote = "origin"; checkout.defaultRemote = "origin";
color.ui = true; color.ui = true;
commit = { template = "~/.gitmessage"; }; commit = {template = "~/.gitmessage";};
core = { core = {
editor = "nvim"; editor = "nvim";
excludesFile = "~/.config/git/ignore"; excludesFile = "~/.config/git/ignore";

View file

@ -1,10 +1,7 @@
{ inputs }: { pkgs, ... }: {inputs}: {pkgs, ...}: let
let
system = pkgs.system; system = pkgs.system;
in in {
{ programs.neovim = inputs.opdavies-nvim.lib.mkHomeManager {inherit system;};
programs.neovim = inputs.opdavies-nvim.lib.mkHomeManager { inherit system; };
home.file.".markdownlint.yaml".text = '' home.file.".markdownlint.yaml".text = ''
default: true default: true

View file

@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
programs.tmux = { programs.tmux = {
enable = true; enable = true;
terminal = "tmux-256color"; terminal = "tmux-256color";

View file

@ -200,19 +200,19 @@
plugins = [ plugins = [
{ {
name = "themes/robbyrussell"; name = "themes/robbyrussell";
tags = [ "from:oh-my-zsh" "as:theme" ]; tags = ["from:oh-my-zsh" "as:theme"];
} }
{ {
name = "plugin/git"; name = "plugin/git";
tags = [ "from:oh-my-zsh" ]; tags = ["from:oh-my-zsh"];
} }
{ {
name = "plugin/vi-mode"; name = "plugin/vi-mode";
tags = [ "from:oh-my-zsh" ]; tags = ["from:oh-my-zsh"];
} }
{ name = "mollifier/cd-gitroot"; } {name = "mollifier/cd-gitroot";}
{ name = "zsh-users/zsh-completions"; } {name = "zsh-users/zsh-completions";}
{ name = "zsh-users/zsh-syntax-highlighting"; } {name = "zsh-users/zsh-syntax-highlighting";}
]; ];
}; };
}; };

View file

@ -1,15 +1,19 @@
{ inputs, pkgs, self, system, username }: {
inputs,
let pkgs,
shared-config = import ../shared/home-manager.nix { inherit inputs pkgs self username; }; self,
shared-packages = import ../shared/home-manager-packages.nix { inherit inputs pkgs; }; system,
username,
}: let
shared-config = import ../shared/home-manager.nix {inherit inputs pkgs self username;};
shared-packages = import ../shared/home-manager-packages.nix {inherit inputs pkgs;};
in in
inputs.home-manager.lib.homeManagerConfiguration { inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ modules = [
{ {
imports = [ shared-config ]; imports = [shared-config];
home.packages = shared-packages; home.packages = shared-packages;
@ -21,4 +25,4 @@ inputs.home-manager.lib.homeManagerConfiguration {
}; };
} }
]; ];
} }