From 05dd85210e465caa44ef7254f2781b2d12ba2882 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 16 Oct 2022 23:49:18 +0200 Subject: Reformat files with alejandra --- flake.nix | 27 +- system/mba.nix | 7 +- system/modules/nextdns.nix | 21 +- system/prefect.nix | 35 +- system/satoshipad.nix | 6 +- system/settings/base.nix | 8 +- system/settings/configuration/berlin.nix | 9 +- system/settings/configuration/british-english.nix | 9 +- system/settings/configuration/england.nix | 9 +- system/settings/configuration/networking.nix | 8 +- system/settings/configuration/nix.nix | 13 +- system/settings/configuration/user.nix | 11 +- system/settings/darwin.nix | 7 +- system/settings/gaming.nix | 42 +- system/settings/hardware/adb.nix | 8 +- system/settings/hardware/audio.nix | 9 +- system/settings/hardware/bare-metal.nix | 17 +- system/settings/hardware/bluetooth-audio.nix | 6 +- system/settings/hardware/bluetooth.nix | 7 +- system/settings/hardware/connman.nix | 11 +- system/settings/hardware/grub2.nix | 10 +- system/settings/hardware/intel-gpu.nix | 8 +- system/settings/hardware/iwd.nix | 8 +- system/settings/hardware/keyboard.nix | 6 +- system/settings/hardware/keyboardio-model01.nix | 9 +- system/settings/hardware/laptop.nix | 12 +- system/settings/hardware/mouse.nix | 8 +- system/settings/hardware/network-manager.nix | 7 +- system/settings/hardware/nitrokey.nix | 7 +- system/settings/hardware/nvidia-gpu.nix | 20 +- system/settings/hardware/nvme-root.nix | 6 +- system/settings/hardware/personal-computer.nix | 7 +- system/settings/hardware/printing.nix | 14 +- system/settings/hardware/systemd-boot.nix | 9 +- system/settings/hardware/thinkpad.nix | 11 +- system/settings/hardware/trackball.nix | 9 +- system/settings/hardware/trezor.nix | 12 +- system/settings/kubernetes.nix | 6 +- system/settings/machines/t470s.nix | 9 +- system/settings/programs/barrier.nix | 8 +- system/settings/programs/base.nix | 4 +- system/settings/programs/gnome.nix | 12 +- system/settings/programs/gnupg.nix | 9 +- system/settings/programs/i3.nix | 9 +- system/settings/programs/kde.nix | 12 +- system/settings/programs/shell.nix | 24 +- system/settings/programs/tor.nix | 9 +- system/settings/programs/window-manager.nix | 6 +- system/settings/satoshipay.nix | 13 +- system/settings/services/airplay-sink.nix | 6 +- system/settings/services/samba.nix | 16 +- system/settings/services/syncthing.nix | 9 +- system/settings/services/virtualisation.nix | 6 +- system/settings/services/xserver.nix | 58 +- system/settings/services/zeroconf.nix | 12 +- system/settings/user-interface.nix | 17 +- user/config.nix | 4 +- user/mba.nix | 6 +- user/modules/eshell.nix | 15 +- user/modules/nvim-coc.nix | 15 +- user/modules/tabnine.nix | 47 +- user/overlays/extra-packages.nix | 3 +- user/packages/lumen/default.nix | 9 +- user/packages/node2nix/default.nix | 27 +- user/packages/node2nix/node-env.nix | 1096 +++++++++++---------- user/packages/node2nix/node-packages.nix | 180 ++-- user/prefect.nix | 6 +- user/satoshipad.nix | 12 +- user/server.nix | 10 +- user/settings/accounting.nix | 6 +- user/settings/base.nix | 64 +- user/settings/chat.nix | 6 +- user/settings/darwin.nix | 65 +- user/settings/development/base.nix | 51 +- user/settings/development/clojure.nix | 6 +- user/settings/development/javascript.nix | 72 +- user/settings/development/lisp.nix | 9 +- user/settings/development/rust.nix | 6 +- user/settings/development/web.nix | 21 +- user/settings/dunst.nix | 6 +- user/settings/emacs.nix | 247 ++--- user/settings/gaming.nix | 6 +- user/settings/git.nix | 6 +- user/settings/gnupg.nix | 6 +- user/settings/golang.nix | 10 +- user/settings/i3.nix | 70 +- user/settings/ledger.nix | 6 +- user/settings/mail.nix | 7 +- user/settings/music-management.nix | 6 +- user/settings/music.nix | 10 +- user/settings/nix.nix | 6 +- user/settings/nixos.nix | 6 +- user/settings/nixpkgs.nix | 15 +- user/settings/passwords.nix | 6 +- user/settings/rofi.nix | 9 +- user/settings/satoshipay.nix | 62 +- user/settings/ssh.nix | 7 +- user/settings/sxhkd.nix | 6 +- user/settings/tabnine.nix | 29 +- user/settings/trezor.nix | 6 +- user/settings/user-interface.nix | 33 +- user/settings/xresources.nix | 6 +- user/settings/zsh.nix | 76 +- 103 files changed, 1724 insertions(+), 1337 deletions(-) diff --git a/flake.nix b/flake.nix index 8ff6394d..d3b6f969 100644 --- a/flake.nix +++ b/flake.nix @@ -13,31 +13,36 @@ }; }; - outputs = { self, darwin, home-manager, nixpkgs, secrets, ... }@attrs: - let - darwinSystem = - "x86_64-darwin"; # aarch64 is still failing on some compiler-rt derivation - darwinPkgs = nixpkgs.legacyPackages.${darwinSystem}; - nixosSystem = "x86_64-linux"; - nixosPkgs = nixpkgs.legacyPackages.${nixosSystem}; + outputs = { + self, + darwin, + home-manager, + nixpkgs, + secrets, + ... + } @ attrs: let + darwinSystem = "x86_64-darwin"; # aarch64 is still failing on some compiler-rt derivation + darwinPkgs = nixpkgs.legacyPackages.${darwinSystem}; + nixosSystem = "x86_64-linux"; + nixosPkgs = nixpkgs.legacyPackages.${nixosSystem}; in { nixosConfigurations.prefect = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = attrs; - modules = [ ./system/prefect.nix ]; + modules = [./system/prefect.nix]; }; darwinConfigurations.mba = darwin.lib.darwinSystem { system = darwinSystem; specialArgs = attrs; - modules = [ ./system/mba.nix ]; + modules = [./system/mba.nix]; }; homeConfigurations."alan@mba" = home-manager.lib.homeManagerConfiguration { pkgs = darwinPkgs; - modules = [ ./user/mba.nix (secrets + "/default.nix") ]; + modules = [./user/mba.nix (secrets + "/default.nix")]; }; homeConfigurations."alan@prefect" = home-manager.lib.homeManagerConfiguration { pkgs = nixosPkgs; - modules = [ ./user/prefect.nix (secrets + "/default.nix") ]; + modules = [./user/prefect.nix (secrets + "/default.nix")]; }; }; } diff --git a/system/mba.nix b/system/mba.nix index afdcec29..d2452c4a 100644 --- a/system/mba.nix +++ b/system/mba.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { imports = [ ./settings/darwin.nix ./settings/programs/base.nix @@ -35,3 +37,4 @@ }; } # vim: sw=2 sts=2 expandtab autoindent smarttab + diff --git a/system/modules/nextdns.nix b/system/modules/nextdns.nix index b6e33728..0c718d57 100644 --- a/system/modules/nextdns.nix +++ b/system/modules/nextdns.nix @@ -1,13 +1,18 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let inherit (pkgs) stdenv; cfg = config.networking.nextdns; - identifyingPrefix = if cfg.identifyDevice then "${config.networking.hostName}-" else ""; + identifyingPrefix = + if cfg.identifyDevice + then "${config.networking.hostName}-" + else ""; kresdConfig = { enable = true; @@ -31,8 +36,7 @@ let }))) ''; }; -in -{ +in { options = { networking.nextdns.enable = mkOption { type = types.bool; @@ -55,7 +59,6 @@ in }; config = mkIf cfg.enable { - assertions = [ { assertion = !(stdenv.isDarwin); diff --git a/system/prefect.nix b/system/prefect.nix index b4eb6f34..8c80ff6f 100644 --- a/system/prefect.nix +++ b/system/prefect.nix @@ -1,6 +1,12 @@ -{ config, pkgs, nixpkgs, nixpkgs-unstable, nixos-hardware, ... }: - -{ imports = [ +{ + config, + pkgs, + nixpkgs, + nixpkgs-unstable, + nixos-hardware, + ... +}: { + imports = [ (nixos-hardware + "/common/pc/ssd") (nixos-hardware + "/common/cpu/amd") @@ -56,15 +62,15 @@ zenpower ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; + boot.initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-amd"]; fileSystems = { "/" = { device = "/dev/disk/by-partlabel/nixos-root"; fsType = "f2fs"; - options = [ "atgc" "gc_merge" "lazytime" "nodiscard" ]; + options = ["atgc" "gc_merge" "lazytime" "nodiscard"]; }; "/boot" = { @@ -75,29 +81,34 @@ "/home" = { device = "/dev/disk/by-partlabel/home"; fsType = "ext4"; - options = [ "lazytime" "nodiscard" ]; + options = ["lazytime" "nodiscard"]; }; "/mnt/data" = { device = "/dev/disk/by-partlabel/data"; fsType = "ntfs3"; - options = [ "uid=1000" "gid=100" "x-systemd-automount" "nofail" ]; + options = ["uid=1000" "gid=100" "x-systemd-automount" "nofail"]; }; "/mnt/games" = { device = "/dev/disk/by-partlabel/games"; fsType = "ntfs3"; - options = [ "uid=1000" "gid=100" "x-systemd-automount" "nofail" ]; + options = ["uid=1000" "gid=100" "x-systemd-automount" "nofail"]; }; "/mnt/windows" = { device = "/dev/disk/by-partlabel/windows"; fsType = "ntfs3"; - options = [ "x-systemd-automount" "nofail" ]; + options = ["x-systemd-automount" "nofail"]; }; }; - swapDevices = [ { label = "swap"; discardPolicy = "once"; } ]; + swapDevices = [ + { + label = "swap"; + discardPolicy = "once"; + } + ]; services.xserver = { xautolock.enable = pkgs.lib.mkForce false; diff --git a/system/satoshipad.nix b/system/satoshipad.nix index 13302537..626f5900 100644 --- a/system/satoshipad.nix +++ b/system/satoshipad.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { imports = [ ./hardware-configuration.nix diff --git a/system/settings/base.nix b/system/settings/base.nix index 35d00faa..809b6847 100644 --- a/system/settings/base.nix +++ b/system/settings/base.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { imports = [ ../modules/nextdns.nix ]; @@ -18,5 +21,4 @@ configID = "abd6e5"; identifyDevice = true; }; - } diff --git a/system/settings/configuration/berlin.nix b/system/settings/configuration/berlin.nix index 6fa4f502..bc8ed1fd 100644 --- a/system/settings/configuration/berlin.nix +++ b/system/settings/configuration/berlin.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ time.timeZone = "Europe/Berlin"; +{ + config, + pkgs, + ... +}: { + time.timeZone = "Europe/Berlin"; location = { latitude = 52.586; longitude = 13.300; diff --git a/system/settings/configuration/british-english.nix b/system/settings/configuration/british-english.nix index 3ff93678..4167016f 100644 --- a/system/settings/configuration/british-english.nix +++ b/system/settings/configuration/british-english.nix @@ -1,4 +1,7 @@ -{ config, pkgs, ... }: - -{ i18n.defaultLocale = "en_GB.UTF-8"; +{ + config, + pkgs, + ... +}: { + i18n.defaultLocale = "en_GB.UTF-8"; } diff --git a/system/settings/configuration/england.nix b/system/settings/configuration/england.nix index 4b54db17..2213ac74 100644 --- a/system/settings/configuration/england.nix +++ b/system/settings/configuration/england.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ time.timeZone = "Europe/London"; +{ + config, + pkgs, + ... +}: { + time.timeZone = "Europe/London"; services.redshift = { latitude = 52.2394; longitude = -0.9416; diff --git a/system/settings/configuration/networking.nix b/system/settings/configuration/networking.nix index 2e93a4ca..8d9f276f 100644 --- a/system/settings/configuration/networking.nix +++ b/system/settings/configuration/networking.nix @@ -1,7 +1,9 @@ -{ config, pkgs, ... }: - { - environment.systemPackages = with pkgs; [ lxqt.lxqt-policykit ]; # provides a default authentification client for policykit + config, + pkgs, + ... +}: { + environment.systemPackages = with pkgs; [lxqt.lxqt-policykit]; # provides a default authentification client for policykit services.gvfs.enable = true; # enables gvfs imports = [ diff --git a/system/settings/configuration/nix.nix b/system/settings/configuration/nix.nix index f152ac27..7ae8f7f6 100644 --- a/system/settings/configuration/nix.nix +++ b/system/settings/configuration/nix.nix @@ -1,10 +1,13 @@ -{ config, pkgs, ... }: - -{ nix = { +{ + config, + pkgs, + ... +}: { + nix = { settings = { cores = 0; auto-optimise-store = true; - trusted-users = [ "@wheel" ]; + trusted-users = ["@wheel"]; }; daemonCPUSchedPolicy = "idle"; @@ -24,7 +27,7 @@ system.autoUpgrade = { enable = true; - flags = [ "--max-jobs" "2" ]; + flags = ["--max-jobs" "2"]; }; systemd.services.nixos-upgrade = { script = pkgs.lib.mkForce '' diff --git a/system/settings/configuration/user.nix b/system/settings/configuration/user.nix index 33b678e9..ccb43323 100644 --- a/system/settings/configuration/user.nix +++ b/system/settings/configuration/user.nix @@ -1,9 +1,12 @@ -{ config, pkgs, ... }: - -{ users.extraUsers.alan = { +{ + config, + pkgs, + ... +}: { + users.extraUsers.alan = { description = "Alan Pearce"; isNormalUser = true; - extraGroups = [ "audio" "wheel" "lp" "adbusers" "docker" "nitrokey" "dialout" "pipewire" "networkmanager" "video" ]; + extraGroups = ["audio" "wheel" "lp" "adbusers" "docker" "nitrokey" "dialout" "pipewire" "networkmanager" "video"]; shell = "/run/current-system/sw/bin/zsh"; initialPassword = "password"; home = "/home/alan"; diff --git a/system/settings/darwin.nix b/system/settings/darwin.nix index 66d2a353..1d64ff3b 100644 --- a/system/settings/darwin.nix +++ b/system/settings/darwin.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { services.nix-daemon = { enable = true; enableSocketListener = true; diff --git a/system/settings/gaming.nix b/system/settings/gaming.nix index 139210cf..3a0c134e 100644 --- a/system/settings/gaming.nix +++ b/system/settings/gaming.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { programs.steam.enable = true; programs.gamemode = { enable = true; @@ -25,7 +27,7 @@ "link.max-buffers" = 16; "log.level" = 2; "default.clock.rate" = 44100; - "default.clock.allowed_rates" = [ 44100 48000 88200 96000 ]; + "default.clock.allowed_rates" = [44100 48000 88200 96000]; "default.clock.quantum" = 32; "default.clock.min-quantum" = 32; "default.clock.max-quantum" = 32; @@ -41,26 +43,26 @@ "rt.time.soft" = 200000; "rt.time.hard" = 200000; }; - flags = [ "ifexists" "nofail" ]; + flags = ["ifexists" "nofail"]; } - { name = "libpipewire-module-protocol-native"; } - { name = "libpipewire-module-profiler"; } - { name = "libpipewire-module-metadata"; } - { name = "libpipewire-module-spa-device-factory"; } - { name = "libpipewire-module-spa-node-factory"; } - { name = "libpipewire-module-client-node"; } - { name = "libpipewire-module-client-device"; } + {name = "libpipewire-module-protocol-native";} + {name = "libpipewire-module-profiler";} + {name = "libpipewire-module-metadata";} + {name = "libpipewire-module-spa-device-factory";} + {name = "libpipewire-module-spa-node-factory";} + {name = "libpipewire-module-client-node";} + {name = "libpipewire-module-client-device";} { name = "libpipewire-module-portal"; - flags = [ "ifexists" "nofail" ]; + flags = ["ifexists" "nofail"]; } { name = "libpipewire-module-access"; args = {}; } - { name = "libpipewire-module-adapter"; } - { name = "libpipewire-module-link-factory"; } - { name = "libpipewire-module-session-manager"; } + {name = "libpipewire-module-adapter";} + {name = "libpipewire-module-link-factory";} + {name = "libpipewire-module-session-manager";} ]; "stream.properties" = { "node.latency" = "32/44100"; @@ -86,12 +88,12 @@ "rt.time.soft" = 200000; "rt.time.hard" = 200000; }; - flags = [ "ifexists" "nofail" ]; + flags = ["ifexists" "nofail"]; } - { name = "libpipewire-module-protocol-native"; } - { name = "libpipewire-module-client-node"; } - { name = "libpipewire-module-adapter"; } - { name = "libpipewire-module-metadata"; } + {name = "libpipewire-module-protocol-native";} + {name = "libpipewire-module-client-node";} + {name = "libpipewire-module-adapter";} + {name = "libpipewire-module-metadata";} { name = "libpipewire-module-protocol-pulse"; args = { diff --git a/system/settings/hardware/adb.nix b/system/settings/hardware/adb.nix index 0c27b380..be151695 100644 --- a/system/settings/hardware/adb.nix +++ b/system/settings/hardware/adb.nix @@ -1,10 +1,12 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { programs.adb.enable = true; users.groups.adbusers = {}; services.udev = { - packages = [ pkgs.android-udev-rules ]; + packages = [pkgs.android-udev-rules]; }; } diff --git a/system/settings/hardware/audio.nix b/system/settings/hardware/audio.nix index 036fb37d..823edaeb 100644 --- a/system/settings/hardware/audio.nix +++ b/system/settings/hardware/audio.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ services.pipewire = { +{ + config, + pkgs, + ... +}: { + services.pipewire = { enable = true; audio.enable = true; alsa.enable = true; diff --git a/system/settings/hardware/bare-metal.nix b/system/settings/hardware/bare-metal.nix index ce8e57e2..0b8ce6d2 100644 --- a/system/settings/hardware/bare-metal.nix +++ b/system/settings/hardware/bare-metal.nix @@ -1,8 +1,11 @@ -{ config, pkgs, ... }: - -{ environment.systemPackages = with pkgs; [ +{ + config, + pkgs, + ... +}: { + environment.systemPackages = with pkgs; [ exfat - efibootmgr + efibootmgr cryptsetup dmidecode hdparm @@ -28,7 +31,7 @@ ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq" ''; - boot.kernelModules = [ "tcp_bbr" ]; + boot.kernelModules = ["tcp_bbr"]; boot.kernel.sysctl = { "net.core.default_qdisc" = "cake"; "net.ipv4.tcp_allowed_congestion_control" = "bbr illinois reno lp"; @@ -44,6 +47,6 @@ }; boot.tmpOnTmpfs = true; - fileSystems."/".options = [ "noatime" "nodiratime" ]; - fileSystems."/home".options = [ "noatime" "nodiratime" ]; + fileSystems."/".options = ["noatime" "nodiratime"]; + fileSystems."/home".options = ["noatime" "nodiratime"]; } diff --git a/system/settings/hardware/bluetooth-audio.nix b/system/settings/hardware/bluetooth-audio.nix index 69f46984..26e3ca70 100644 --- a/system/settings/hardware/bluetooth-audio.nix +++ b/system/settings/hardware/bluetooth-audio.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { hardware = { bluetooth = { package = pkgs.bluezFull; diff --git a/system/settings/hardware/bluetooth.nix b/system/settings/hardware/bluetooth.nix index 258fdb29..54a1792a 100644 --- a/system/settings/hardware/bluetooth.nix +++ b/system/settings/hardware/bluetooth.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { hardware = { bluetooth = { enable = true; diff --git a/system/settings/hardware/connman.nix b/system/settings/hardware/connman.nix index 91b6aab1..e8e04244 100644 --- a/system/settings/hardware/connman.nix +++ b/system/settings/hardware/connman.nix @@ -1,9 +1,12 @@ -{ config, pkgs, ... }: - -{ services.connman = { +{ + config, + pkgs, + ... +}: { + services.connman = { enable = true; enableVPN = false; - extraFlags = [ "--nodnsproxy" ]; + extraFlags = ["--nodnsproxy"]; }; networking.useDHCP = false; diff --git a/system/settings/hardware/grub2.nix b/system/settings/hardware/grub2.nix index cd1fd619..a020baa7 100644 --- a/system/settings/hardware/grub2.nix +++ b/system/settings/hardware/grub2.nix @@ -1,6 +1,10 @@ -{ config, pkgs, lib, ... }: - -{ boot.loader = { +{ + config, + pkgs, + lib, + ... +}: { + boot.loader = { grub = { enable = true; splashImage = null; diff --git a/system/settings/hardware/intel-gpu.nix b/system/settings/hardware/intel-gpu.nix index 3503c315..c606de79 100644 --- a/system/settings/hardware/intel-gpu.nix +++ b/system/settings/hardware/intel-gpu.nix @@ -1,13 +1,15 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { # https://wiki.gentoo.org/wiki/Intel#Feature_support services.xserver = { useGlamor = true; deviceSection = '' Option "DRI" "3" ''; - videoDrivers = [ "intel" ]; + videoDrivers = ["intel"]; }; boot.kernelParams = [ diff --git a/system/settings/hardware/iwd.nix b/system/settings/hardware/iwd.nix index f1a67764..c0090f26 100644 --- a/system/settings/hardware/iwd.nix +++ b/system/settings/hardware/iwd.nix @@ -1,10 +1,12 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { networking.wireless.iwd = { enable = true; }; - users.users.alan.extraGroups = [ "network" ]; + users.users.alan.extraGroups = ["network"]; services.connman.wifi.backend = "iwd"; } diff --git a/system/settings/hardware/keyboard.nix b/system/settings/hardware/keyboard.nix index c967d561..3ff11b83 100644 --- a/system/settings/hardware/keyboard.nix +++ b/system/settings/hardware/keyboard.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { services.xserver = { layout = "us"; xkbVariant = "intl-unicode"; diff --git a/system/settings/hardware/keyboardio-model01.nix b/system/settings/hardware/keyboardio-model01.nix index 9c44a916..c10533bd 100644 --- a/system/settings/hardware/keyboardio-model01.nix +++ b/system/settings/hardware/keyboardio-model01.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ services.udev.extraRules = '' +{ + config, + pkgs, + ... +}: { + services.udev.extraRules = '' SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2300", SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1", ENV{ID_MM_CANDIDATE}:="0" SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2301", SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1", ENV{ID_MM_CANDIDATE}:="0" ''; diff --git a/system/settings/hardware/laptop.nix b/system/settings/hardware/laptop.nix index 946dbda7..ee67d38f 100644 --- a/system/settings/hardware/laptop.nix +++ b/system/settings/hardware/laptop.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { imports = [ ./bluetooth.nix ./bluetooth-audio.nix @@ -10,10 +13,9 @@ ../user-interface.nix ]; - boot.kernelModules = [ "coretemp" ]; + boot.kernelModules = ["coretemp"]; environment.systemPackages = with pkgs; [ - powerstat powertop @@ -28,7 +30,7 @@ enable = true; defaultTarget = "common"; }; - systemd.services.autorandr.wantedBy = [ "graphical.target" ]; + systemd.services.autorandr.wantedBy = ["graphical.target"]; environment.etc.autorandr = { enable = true; diff --git a/system/settings/hardware/mouse.nix b/system/settings/hardware/mouse.nix index 83e76d71..6104ea47 100644 --- a/system/settings/hardware/mouse.nix +++ b/system/settings/hardware/mouse.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - -{ +{ + config, + pkgs, + ... +}: { services.xserver.libinput = { enable = true; mouse = { diff --git a/system/settings/hardware/network-manager.nix b/system/settings/hardware/network-manager.nix index 6ab0c818..22711b10 100644 --- a/system/settings/hardware/network-manager.nix +++ b/system/settings/hardware/network-manager.nix @@ -1,6 +1,9 @@ -{ config, lib, pkgs, ... }: - { + config, + lib, + pkgs, + ... +}: { networking = { networkmanager = { enable = true; diff --git a/system/settings/hardware/nitrokey.nix b/system/settings/hardware/nitrokey.nix index a77ce00c..58e62195 100644 --- a/system/settings/hardware/nitrokey.nix +++ b/system/settings/hardware/nitrokey.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { hardware.nitrokey = { enable = true; }; diff --git a/system/settings/hardware/nvidia-gpu.nix b/system/settings/hardware/nvidia-gpu.nix index 052cd678..4024f069 100644 --- a/system/settings/hardware/nvidia-gpu.nix +++ b/system/settings/hardware/nvidia-gpu.nix @@ -1,16 +1,18 @@ -{ config, pkgs, lib, ... }: - -let - nvidia_x11 = config.boot.kernelPackages.nvidia_x11; -in { - services.xserver.videoDrivers = [ "nvidia" ]; + config, + pkgs, + lib, + ... +}: let + nvidia_x11 = config.boot.kernelPackages.nvidia_x11; +in { + services.xserver.videoDrivers = ["nvidia"]; boot = { - blacklistedKernelModules = [ "nouveau" ]; - extraModulePackages = [ nvidia_x11 ]; + blacklistedKernelModules = ["nouveau"]; + extraModulePackages = [nvidia_x11]; }; - environment.systemPackages = [ nvidia_x11 ]; + environment.systemPackages = [nvidia_x11]; hardware.nvidia = { powerManagement = { enable = true; diff --git a/system/settings/hardware/nvme-root.nix b/system/settings/hardware/nvme-root.nix index 3ba26f50..310a0482 100644 --- a/system/settings/hardware/nvme-root.nix +++ b/system/settings/hardware/nvme-root.nix @@ -1,5 +1,7 @@ -{ config, pkgs, ...}: - { + config, + pkgs, + ... +}: { boot.kernelParams = ["elevator=none"]; } diff --git a/system/settings/hardware/personal-computer.nix b/system/settings/hardware/personal-computer.nix index e8574b3d..e7160950 100644 --- a/system/settings/hardware/personal-computer.nix +++ b/system/settings/hardware/personal-computer.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_zen; powerManagement.cpuFreqGovernor = "schedutil"; } diff --git a/system/settings/hardware/printing.nix b/system/settings/hardware/printing.nix index fb31e79f..474b37b7 100644 --- a/system/settings/hardware/printing.nix +++ b/system/settings/hardware/printing.nix @@ -1,13 +1,17 @@ -{ config, pkgs, lib, ... }: - -{ services.printing.enable = true; +{ + config, + pkgs, + lib, + ... +}: { + services.printing.enable = true; systemd.services.cups.wantedBy = lib.mkForce []; - systemd.sockets.cups.wantedBy = [ "sockets.target" ]; + systemd.sockets.cups.wantedBy = ["sockets.target"]; systemd.services.cups-browsed.wantedBy = lib.mkForce []; systemd.timers.cups-browsed = { description = "Delayed startup of CUPS Remote Printer Discovery"; - wantedBy = [ "timers.target" ]; + wantedBy = ["timers.target"]; timerConfig = { OnActiveSec = "2 min"; }; diff --git a/system/settings/hardware/systemd-boot.nix b/system/settings/hardware/systemd-boot.nix index bc5fca59..e8c06527 100644 --- a/system/settings/hardware/systemd-boot.nix +++ b/system/settings/hardware/systemd-boot.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ boot.loader.systemd-boot = { +{ + config, + pkgs, + ... +}: { + boot.loader.systemd-boot = { enable = true; editor = false; # Don't allow modification }; diff --git a/system/settings/hardware/thinkpad.nix b/system/settings/hardware/thinkpad.nix index 4f4e6b8c..99d91263 100644 --- a/system/settings/hardware/thinkpad.nix +++ b/system/settings/hardware/thinkpad.nix @@ -1,7 +1,10 @@ -{ config, pkgs, ... }: - -{ boot.kernelModules = [ ]; - boot.blacklistedKernelModules = [ "thinkpad_ec" ]; +{ + config, + pkgs, + ... +}: { + boot.kernelModules = []; + boot.blacklistedKernelModules = ["thinkpad_ec"]; boot.extraModulePackages = with config.boot.kernelPackages; [ acpi_call ]; diff --git a/system/settings/hardware/trackball.nix b/system/settings/hardware/trackball.nix index 9aa5abc0..7445c5bb 100644 --- a/system/settings/hardware/trackball.nix +++ b/system/settings/hardware/trackball.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ services.xserver.config = '' +{ + config, + pkgs, + ... +}: { + services.xserver.config = '' Section "InputClass" Identifier "Trackball (No Acceleration)" MatchIsPointer "yes" diff --git a/system/settings/hardware/trezor.nix b/system/settings/hardware/trezor.nix index 60867e07..e24fc92e 100644 --- a/system/settings/hardware/trezor.nix +++ b/system/settings/hardware/trezor.nix @@ -1,10 +1,14 @@ -{ config, lib, pkgs, ... }: - -{ services.trezord.enable = true; +{ + config, + lib, + pkgs, + ... +}: { + services.trezord.enable = true; environment.systemPackages = with pkgs; [ gnupg pinentry - (python3.withPackages(ps: with ps; [ trezor_agent wheel ])) + (python3.withPackages (ps: with ps; [trezor_agent wheel])) trezor-suite ]; programs.gnupg.agent = { diff --git a/system/settings/kubernetes.nix b/system/settings/kubernetes.nix index 68bcb627..8c171fc5 100644 --- a/system/settings/kubernetes.nix +++ b/system/settings/kubernetes.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { networking.bridges = { cbr0.interfaces = []; }; diff --git a/system/settings/machines/t470s.nix b/system/settings/machines/t470s.nix index 7790ce28..c1a82912 100644 --- a/system/settings/machines/t470s.nix +++ b/system/settings/machines/t470s.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ hardware.usbWwan.enable = false; # unused +{ + config, + pkgs, + ... +}: { + hardware.usbWwan.enable = false; # unused systemd.services.ModemManager.enable = false; hardware.enableRedistributableFirmware = true; diff --git a/system/settings/programs/barrier.nix b/system/settings/programs/barrier.nix index 9a73620d..788021d5 100644 --- a/system/settings/programs/barrier.nix +++ b/system/settings/programs/barrier.nix @@ -1,7 +1,11 @@ -{ config, pkgs, ... }: { +{ + config, + pkgs, + ... +}: { environment.systemPackages = with pkgs; [ barrier ]; - networking.firewall.allowedTCPPorts = [ 24800 ]; + networking.firewall.allowedTCPPorts = [24800]; } diff --git a/system/settings/programs/base.nix b/system/settings/programs/base.nix index 1024aedd..f09beb75 100644 --- a/system/settings/programs/base.nix +++ b/system/settings/programs/base.nix @@ -1,6 +1,4 @@ -{ pkgs, ...}: - -{ +{pkgs, ...}: { environment.systemPackages = with pkgs; [ cachix home-manager diff --git a/system/settings/programs/gnome.nix b/system/settings/programs/gnome.nix index 13309a6e..3ccac864 100644 --- a/system/settings/programs/gnome.nix +++ b/system/settings/programs/gnome.nix @@ -1,7 +1,11 @@ -{ config, lib, pkgs, ... }: - -with lib; -{ services = { +{ + config, + lib, + pkgs, + ... +}: +with lib; { + services = { gnome3 = { gnome-documents.enable = false; gnome-user-share.enable = false; diff --git a/system/settings/programs/gnupg.nix b/system/settings/programs/gnupg.nix index 663bcb3c..9899c23b 100644 --- a/system/settings/programs/gnupg.nix +++ b/system/settings/programs/gnupg.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { environment.systemPackages = with pkgs; [ gnupg pinentry - (python3.withPackages(ps: with ps; [ trezor_agent wheel ])) + (python3.withPackages (ps: with ps; [trezor_agent wheel])) ]; environment.variables.GNUPGHOME = "$HOME/.gnupg/trezor/"; } diff --git a/system/settings/programs/i3.nix b/system/settings/programs/i3.nix index ab1fcca4..4cf4a82a 100644 --- a/system/settings/programs/i3.nix +++ b/system/settings/programs/i3.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ services.xserver.windowManager = { +{ + config, + pkgs, + ... +}: { + services.xserver.windowManager = { i3 = { enable = true; extraSessionCommands = '' diff --git a/system/settings/programs/kde.nix b/system/settings/programs/kde.nix index 2faad513..9d77eeb5 100644 --- a/system/settings/programs/kde.nix +++ b/system/settings/programs/kde.nix @@ -1,7 +1,11 @@ -{ config, lib, pkgs, ... }: - -with lib; -{ services = { +{ + config, + lib, + pkgs, + ... +}: +with lib; { + services = { xserver = { desktopManager = { plasma5.enable = true; diff --git a/system/settings/programs/shell.nix b/system/settings/programs/shell.nix index bf8fc3aa..6f4b793a 100644 --- a/system/settings/programs/shell.nix +++ b/system/settings/programs/shell.nix @@ -1,11 +1,19 @@ -{ config, pkgs, ... }: - { - programs.zsh = { - enable = true; - promptInit = ""; - } // (if pkgs.stdenv.isDarwin then {} else { - enableGlobalCompInit = false; - }); + config, + pkgs, + ... +}: { + programs.zsh = + { + enable = true; + promptInit = ""; + } + // ( + if pkgs.stdenv.isDarwin + then {} + else { + enableGlobalCompInit = false; + } + ); programs.bash.enableCompletion = true; } diff --git a/system/settings/programs/tor.nix b/system/settings/programs/tor.nix index 48106e08..80e2fdf2 100644 --- a/system/settings/programs/tor.nix +++ b/system/settings/programs/tor.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { services.tor = { enable = true; client = { @@ -17,7 +20,7 @@ systemd.services.tor.wantedBy = lib.mkForce []; systemd.timers.tor = { description = "Delayed startup of Tor"; - wantedBy = [ "timers.target" ]; + wantedBy = ["timers.target"]; timerConfig = { OnActiveSec = "1 min"; }; diff --git a/system/settings/programs/window-manager.nix b/system/settings/programs/window-manager.nix index b2d94929..bad60797 100644 --- a/system/settings/programs/window-manager.nix +++ b/system/settings/programs/window-manager.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { services.xserver = { desktopManager.xterm.enable = false; diff --git a/system/settings/satoshipay.nix b/system/settings/satoshipay.nix index 9e185570..96c69711 100644 --- a/system/settings/satoshipay.nix +++ b/system/settings/satoshipay.nix @@ -1,6 +1,10 @@ -{ config, pkgs, fetchurl, lib, ... }: - -let +{ + config, + pkgs, + fetchurl, + lib, + ... +}: let dockerConfig = { ipv6 = true; fixed-cidr-v6 = "fd69:2074:9fcd:b0fd::/64"; @@ -8,8 +12,7 @@ let buildkit = true; }; }; -in -{ +in { virtualisation = { docker = { enable = true; diff --git a/system/settings/services/airplay-sink.nix b/system/settings/services/airplay-sink.nix index 617adaa2..4621706e 100644 --- a/system/settings/services/airplay-sink.nix +++ b/system/settings/services/airplay-sink.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { services.pipewire.systemWide = false; services.shairport-sync = { enable = true; diff --git a/system/settings/services/samba.nix b/system/settings/services/samba.nix index 63283e88..729a6756 100644 --- a/system/settings/services/samba.nix +++ b/system/settings/services/samba.nix @@ -1,16 +1,16 @@ -{ config, pkgs, ... }: - -let - workgroup = "WORKGROUP"; - -in { + config, + pkgs, + ... +}: let + workgroup = "WORKGROUP"; +in { services.samba-wsdd = { inherit workgroup; enable = true; }; - networking.firewall.allowedTCPPorts = [ 5357 ]; - networking.firewall.allowedUDPPorts = [ 3702 ]; + networking.firewall.allowedTCPPorts = [5357]; + networking.firewall.allowedUDPPorts = [3702]; services.samba = { enable = true; diff --git a/system/settings/services/syncthing.nix b/system/settings/services/syncthing.nix index c3aa8086..b504bde3 100644 --- a/system/settings/services/syncthing.nix +++ b/system/settings/services/syncthing.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ services.syncthing = { +{ + config, + pkgs, + ... +}: { + services.syncthing = { enable = true; user = "alan"; group = "users"; diff --git a/system/settings/services/virtualisation.nix b/system/settings/services/virtualisation.nix index 200ffa62..8056387c 100644 --- a/system/settings/services/virtualisation.nix +++ b/system/settings/services/virtualisation.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { virtualisation.libvirtd = { enable = true; onBoot = "ignore"; diff --git a/system/settings/services/xserver.nix b/system/settings/services/xserver.nix index c78693c1..7e2a7c49 100644 --- a/system/settings/services/xserver.nix +++ b/system/settings/services/xserver.nix @@ -1,7 +1,11 @@ -{ config, lib, pkgs, ... }: - -with lib; -{ services.xserver = { +{ + config, + lib, + pkgs, + ... +}: +with lib; { + services.xserver = { enable = true; enableCtrlAltBackspace = true; exportConfiguration = true; @@ -37,9 +41,9 @@ with lib; }; useEmbeddedBitmaps = !config.fonts.fontconfig.antialias; defaultFonts = { - monospace = [ "IBM Plex Mono" ]; - sansSerif = [ "Cantarell" ]; - serif = [ "Times New Roman" ]; + monospace = ["IBM Plex Mono"]; + sansSerif = ["Cantarell"]; + serif = ["Times New Roman"]; }; localConf = '' @@ -57,28 +61,30 @@ with lib; ''; }; - fonts = with pkgs; [ - gohufont - dina-font - terminus_font + fonts = with pkgs; + [ + gohufont + dina-font + terminus_font - corefonts + corefonts - emacs-all-the-icons-fonts - font-awesome_5 - xorg.fontmiscmisc - xorg.fontcursormisc - ] ++ lib.optionals config.fonts.fontconfig.antialias [ - cantarell-fonts + emacs-all-the-icons-fonts + font-awesome_5 + xorg.fontmiscmisc + xorg.fontcursormisc + ] + ++ lib.optionals config.fonts.fontconfig.antialias [ + cantarell-fonts - fira - fira-code - fira-mono - ibm-plex + fira + fira-code + fira-mono + ibm-plex - source-code-pro - source-sans-pro - source-serif-pro - ]; + source-code-pro + source-sans-pro + source-serif-pro + ]; }; } diff --git a/system/settings/services/zeroconf.nix b/system/settings/services/zeroconf.nix index 98bde1da..6859cfd5 100644 --- a/system/settings/services/zeroconf.nix +++ b/system/settings/services/zeroconf.nix @@ -1,6 +1,10 @@ -{ config, pkgs, lib, ... }: - -{ services.avahi = { +{ + config, + pkgs, + lib, + ... +}: { + services.avahi = { enable = true; nssmdns = true; ipv6 = true; @@ -15,7 +19,7 @@ systemd.services.avahi-daemon.wantedBy = lib.mkForce []; systemd.timers.avahi-daemon = { description = "Delayed startup of Avahi"; - wantedBy = [ "timers.target" ]; + wantedBy = ["timers.target"]; timerConfig = { OnActiveSec = "1 min"; }; diff --git a/system/settings/user-interface.nix b/system/settings/user-interface.nix index 078f71cb..7fec2f88 100644 --- a/system/settings/user-interface.nix +++ b/system/settings/user-interface.nix @@ -1,9 +1,14 @@ -{ config, pkgs, lib, makeDesktopItem, ... }: - -{ documentation.info.enable = true; +{ + config, + pkgs, + lib, + makeDesktopItem, + ... +}: { + documentation.info.enable = true; nixpkgs.config.firefox.enableOfficialBranding = true; - environment.pathsToLink = [ "/share/zsh" ]; + environment.pathsToLink = ["/share/zsh"]; environment.systemPackages = with pkgs; [ aria2 @@ -31,7 +36,7 @@ services.devmon.enable = true; systemd.user.services.trash-clean = { - path = with pkgs; [ trash-cli ]; + path = with pkgs; [trash-cli]; description = "Remove old files from FreeDesktop.org trash"; serviceConfig = { @@ -40,7 +45,7 @@ script = "trash-empty 30"; }; systemd.user.timers.trash-clean = { - wantedBy = [ "default.target" ]; + wantedBy = ["default.target"]; timerConfig = { OnCalendar = "weekly"; Persistent = true; diff --git a/user/config.nix b/user/config.nix index 53c7c8e2..d138ff20 100644 --- a/user/config.nix +++ b/user/config.nix @@ -1,4 +1,4 @@ -{ pkgs }: { +{pkgs}: { allowUnfree = true; - allowUnfreePredicate = (pkg: true); + allowUnfreePredicate = pkg: true; } diff --git a/user/mba.nix b/user/mba.nix index 9183108d..93418622 100644 --- a/user/mba.nix +++ b/user/mba.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { imports = [ ./settings/base.nix ./settings/development/base.nix diff --git a/user/modules/eshell.nix b/user/modules/eshell.nix index eaa4a206..fd108af6 100644 --- a/user/modules/eshell.nix +++ b/user/modules/eshell.nix @@ -1,12 +1,15 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let cfg = config.programs.emacs; +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.programs.emacs; in { options.programs.emacs.eshell = { aliases = mkOption { - default = { }; + default = {}; type = types.attrsOf types.str; example = { ll = "ls -l $*"; diff --git a/user/modules/nvim-coc.nix b/user/modules/nvim-coc.nix index 5aa462f0..bc8fbb19 100644 --- a/user/modules/nvim-coc.nix +++ b/user/modules/nvim-coc.nix @@ -1,12 +1,13 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let inherit (pkgs) stdenv; cfg = config.programs.neovim.coc; -in -{ +in { options.programs.neovim.coc = { config = mkOption { type = types.attrs; diff --git a/user/modules/tabnine.nix b/user/modules/tabnine.nix index 16065ab1..261176dc 100644 --- a/user/modules/tabnine.nix +++ b/user/modules/tabnine.nix @@ -1,32 +1,35 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let inherit (pkgs) stdenv; cfg = config.programs.tabnine; lspConfigFile = config: - pkgs.runCommand "TabNine.toml" - { - buildInputs = [ pkgs.remarshal ]; - preferLocalBuild = true; - allowSubstitutes = false; - } - '' - remarshal -if json -of toml \ - < ${pkgs.writeText "config.json" (builtins.toJSON cfg.lspConfig)} \ - | sed -e 's/^\["\(.*\)"\]/[\1]/' \ - > $out - ''; -in -{ - + pkgs.runCommand "TabNine.toml" + { + buildInputs = [pkgs.remarshal]; + preferLocalBuild = true; + allowSubstitutes = false; + } + '' + remarshal -if json -of toml \ + < ${pkgs.writeText "config.json" (builtins.toJSON cfg.lspConfig)} \ + | sed -e 's/^\["\(.*\)"\]/[\1]/' \ + > $out + ''; +in { options.programs.tabnine = { enable = mkEnableOption "TabNine, Smart Compose for code."; configDir = mkOption { type = types.str; - default = if stdenv.isDarwin then "Library/Preferences/TabNine" else "${config.xdg.configHome}/TabNine"; + default = + if stdenv.isDarwin + then "Library/Preferences/TabNine" + else "${config.xdg.configHome}/TabNine"; description = '' Location of TabNine configuration directory relative to \$HOME ''; @@ -34,7 +37,7 @@ in config = mkOption { type = types.attrs; - default = { }; + default = {}; description = '' TabNine configuration written to \${configDir}/tabnine_config.json diff --git a/user/overlays/extra-packages.nix b/user/overlays/extra-packages.nix index 0329120b..ec315586 100644 --- a/user/overlays/extra-packages.nix +++ b/user/overlays/extra-packages.nix @@ -1,4 +1,3 @@ -self: super: -{ +self: super: { lumen = super.callPackage ../packages/lumen {}; } diff --git a/user/packages/lumen/default.nix b/user/packages/lumen/default.nix index b4406855..91e1b726 100644 --- a/user/packages/lumen/default.nix +++ b/user/packages/lumen/default.nix @@ -1,5 +1,10 @@ -{ stdenv, lib, go, buildGoPackage, fetchFromGitHub }: - +{ + stdenv, + lib, + go, + buildGoPackage, + fetchFromGitHub, +}: buildGoPackage rec { pname = "lumen"; version = "0.4.1"; diff --git a/user/packages/node2nix/default.nix b/user/packages/node2nix/default.nix index 66f82712..09eea0fe 100644 --- a/user/packages/node2nix/default.nix +++ b/user/packages/node2nix/default.nix @@ -1,17 +1,22 @@ # This file has been generated by node2nix 1.11.1. Do not edit! - -{pkgs ? import { - inherit system; -}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-18_x"}: - -let +{ + pkgs ? + import { + inherit system; + }, + system ? builtins.currentSystem, + nodejs ? pkgs."nodejs-18_x", +}: let nodeEnv = import ./node-env.nix { inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript; inherit pkgs nodejs; - libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; + libtool = + if pkgs.stdenv.isDarwin + then pkgs.darwin.cctools + else null; }; in -import ./node-packages.nix { - inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit; - inherit nodeEnv; -} + import ./node-packages.nix { + inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit; + inherit nodeEnv; + } diff --git a/user/packages/node2nix/node-env.nix b/user/packages/node2nix/node-env.nix index 0dd75272..b81347da 100644 --- a/user/packages/node2nix/node-env.nix +++ b/user/packages/node2nix/node-env.nix @@ -1,12 +1,25 @@ # This file originates from node2nix - -{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}: - -let +{ + lib, + stdenv, + nodejs, + python2, + pkgs, + libtool, + runCommand, + writeTextFile, + writeShellScript, +}: let # Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master - utillinux = if pkgs ? utillinux then pkgs.utillinux else pkgs.util-linux; + utillinux = + if pkgs ? utillinux + then pkgs.utillinux + else pkgs.util-linux; - python = if nodejs ? python then nodejs.python else python2; + python = + if nodejs ? python + then nodejs.python + else python2; # Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise tarWrapper = runCommand "tarWrapper" {} '' @@ -21,13 +34,16 @@ let ''; # Function that generates a TGZ file from a NPM project - buildNodeSourceDist = - { name, version, src, ... }: - + buildNodeSourceDist = { + name, + version, + src, + ... + }: stdenv.mkDerivation { name = "node-tarball-${name}-${version}"; inherit src; - buildInputs = [ nodejs ]; + buildInputs = [nodejs]; buildPhase = '' export HOME=$TMPDIR tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts) @@ -40,468 +56,495 @@ let ''; }; - # Common shell logic - installPackage = writeShellScript "install-package" '' - installPackage() { - local packageName=$1 src=$2 + # Common shell logic + installPackage = writeShellScript "install-package" '' + installPackage() { + local packageName=$1 src=$2 - local strippedName + local strippedName - local DIR=$PWD - cd $TMPDIR + local DIR=$PWD + cd $TMPDIR - unpackFile $src + unpackFile $src - # Make the base dir in which the target dependency resides first - mkdir -p "$(dirname "$DIR/$packageName")" + # Make the base dir in which the target dependency resides first + mkdir -p "$(dirname "$DIR/$packageName")" - if [ -f "$src" ] - then - # Figure out what directory has been unpacked - packageDir="$(find . -maxdepth 1 -type d | tail -1)" + if [ -f "$src" ] + then + # Figure out what directory has been unpacked + packageDir="$(find . -maxdepth 1 -type d | tail -1)" - # Restore write permissions to make building work - find "$packageDir" -type d -exec chmod u+x {} \; - chmod -R u+w "$packageDir" + # Restore write permissions to make building work + find "$packageDir" -type d -exec chmod u+x {} \; + chmod -R u+w "$packageDir" - # Move the extracted tarball into the output folder - mv "$packageDir" "$DIR/$packageName" - elif [ -d "$src" ] - then - # Get a stripped name (without hash) of the source directory. - # On old nixpkgs it's already set internally. - if [ -z "$strippedName" ] - then - strippedName="$(stripHash $src)" - fi + # Move the extracted tarball into the output folder + mv "$packageDir" "$DIR/$packageName" + elif [ -d "$src" ] + then + # Get a stripped name (without hash) of the source directory. + # On old nixpkgs it's already set internally. + if [ -z "$strippedName" ] + then + strippedName="$(stripHash $src)" + fi - # Restore write permissions to make building work - chmod -R u+w "$strippedName" + # Restore write permissions to make building work + chmod -R u+w "$strippedName" - # Move the extracted directory into the output folder - mv "$strippedName" "$DIR/$packageName" - fi + # Move the extracted directory into the output folder + mv "$strippedName" "$DIR/$packageName" + fi - # Change to the package directory to install dependencies - cd "$DIR/$packageName" - } - ''; + # Change to the package directory to install dependencies + cd "$DIR/$packageName" + } + ''; - # Bundle the dependencies of the package - # - # Only include dependencies if they don't exist. They may also be bundled in the package. - includeDependencies = {dependencies}: + # Bundle the dependencies of the package + # + # Only include dependencies if they don't exist. They may also be bundled in the package. + includeDependencies = {dependencies}: lib.optionalString (dependencies != []) ( '' mkdir -p node_modules cd node_modules '' - + (lib.concatMapStrings (dependency: - '' - if [ ! -e "${dependency.packageName}" ]; then - ${composePackage dependency} - fi - '' - ) dependencies) + + (lib.concatMapStrings ( + dependency: '' + if [ ! -e "${dependency.packageName}" ]; then + ${composePackage dependency} + fi + '' + ) + dependencies) + '' cd .. '' ); - # Recursively composes the dependencies of a package - composePackage = { name, packageName, src, dependencies ? [], ... }@args: + # Recursively composes the dependencies of a package + composePackage = { + name, + packageName, + src, + dependencies ? [], + ... + } @ args: builtins.addErrorContext "while evaluating node package '${packageName}'" '' installPackage "${packageName}" "${src}" - ${includeDependencies { inherit dependencies; }} - cd .. - ${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."} - ''; - - pinpointDependencies = {dependencies, production}: - let - pinpointDependenciesFromPackageJSON = writeTextFile { - name = "pinpointDependencies.js"; - text = '' - var fs = require('fs'); - var path = require('path'); - - function resolveDependencyVersion(location, name) { - if(location == process.env['NIX_STORE']) { - return null; - } else { - var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json"); - - if(fs.existsSync(dependencyPackageJSON)) { - var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON)); - - if(dependencyPackageObj.name == name) { - return dependencyPackageObj.version; - } - } else { - return resolveDependencyVersion(path.resolve(location, ".."), name); - } - } - } - - function replaceDependencies(dependencies) { - if(typeof dependencies == "object" && dependencies !== null) { - for(var dependency in dependencies) { - var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency); - - if(resolvedVersion === null) { - process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n"); - } else { - dependencies[dependency] = resolvedVersion; - } - } - } - } - - /* Read the package.json configuration */ - var packageObj = JSON.parse(fs.readFileSync('./package.json')); - - /* Pinpoint all dependencies */ - replaceDependencies(packageObj.dependencies); - if(process.argv[2] == "development") { - replaceDependencies(packageObj.devDependencies); - } - else { - packageObj.devDependencies = {}; - } - replaceDependencies(packageObj.optionalDependencies); - replaceDependencies(packageObj.peerDependencies); - - /* Write the fixed package.json file */ - fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2)); - ''; - }; - in - '' - node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"} - - ${lib.optionalString (dependencies != []) - '' - if [ -d node_modules ] - then - cd node_modules - ${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies} - cd .. - fi - ''} - ''; - - # Recursively traverses all dependencies of a package and pinpoints all - # dependencies in the package.json file to the versions that are actually - # being used. - - pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args: - '' - if [ -d "${packageName}" ] - then - cd "${packageName}" - ${pinpointDependencies { inherit dependencies production; }} + ${includeDependencies {inherit dependencies;}} cd .. ${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."} - fi ''; - # Extract the Node.js source code which is used to compile packages with - # native bindings - nodeSources = runCommand "node-sources" {} '' - tar --no-same-owner --no-same-permissions -xf ${nodejs.src} - mv node-* $out - ''; - - # Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty) - addIntegrityFieldsScript = writeTextFile { - name = "addintegrityfields.js"; + pinpointDependencies = { + dependencies, + production, + }: let + pinpointDependenciesFromPackageJSON = writeTextFile { + name = "pinpointDependencies.js"; text = '' var fs = require('fs'); var path = require('path'); - function augmentDependencies(baseDir, dependencies) { - for(var dependencyName in dependencies) { - var dependency = dependencies[dependencyName]; - - // Open package.json and augment metadata fields - var packageJSONDir = path.join(baseDir, "node_modules", dependencyName); - var packageJSONPath = path.join(packageJSONDir, "package.json"); + function resolveDependencyVersion(location, name) { + if(location == process.env['NIX_STORE']) { + return null; + } else { + var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json"); - if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored - console.log("Adding metadata fields to: "+packageJSONPath); - var packageObj = JSON.parse(fs.readFileSync(packageJSONPath)); + if(fs.existsSync(dependencyPackageJSON)) { + var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON)); - if(dependency.integrity) { - packageObj["_integrity"] = dependency.integrity; - } else { - packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads. + if(dependencyPackageObj.name == name) { + return dependencyPackageObj.version; } - - if(dependency.resolved) { - packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided } else { - packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories. + return resolveDependencyVersion(path.resolve(location, ".."), name); } - - if(dependency.from !== undefined) { // Adopt from property if one has been provided - packageObj["_from"] = dependency.from; } - - fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2)); } - // Augment transitive dependencies - if(dependency.dependencies !== undefined) { - augmentDependencies(packageJSONDir, dependency.dependencies); + function replaceDependencies(dependencies) { + if(typeof dependencies == "object" && dependencies !== null) { + for(var dependency in dependencies) { + var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency); + + if(resolvedVersion === null) { + process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n"); + } else { + dependencies[dependency] = resolvedVersion; } } } - - if(fs.existsSync("./package-lock.json")) { - var packageLock = JSON.parse(fs.readFileSync("./package-lock.json")); - - if(![1, 2].includes(packageLock.lockfileVersion)) { - process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n"); - process.exit(1); } - if(packageLock.dependencies !== undefined) { - augmentDependencies(".", packageLock.dependencies); + /* Read the package.json configuration */ + var packageObj = JSON.parse(fs.readFileSync('./package.json')); + + /* Pinpoint all dependencies */ + replaceDependencies(packageObj.dependencies); + if(process.argv[2] == "development") { + replaceDependencies(packageObj.devDependencies); } + else { + packageObj.devDependencies = {}; } + replaceDependencies(packageObj.optionalDependencies); + replaceDependencies(packageObj.peerDependencies); + + /* Write the fixed package.json file */ + fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2)); ''; }; + in '' + node ${pinpointDependenciesFromPackageJSON} ${ + if production + then "production" + else "development" + } + + ${lib.optionalString (dependencies != []) + '' + if [ -d node_modules ] + then + cd node_modules + ${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies} + cd .. + fi + ''} + ''; - # Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes - reconstructPackageLock = writeTextFile { - name = "reconstructpackagelock.js"; - text = '' - var fs = require('fs'); - var path = require('path'); + # Recursively traverses all dependencies of a package and pinpoints all + # dependencies in the package.json file to the versions that are actually + # being used. + + pinpointDependenciesOfPackage = { + packageName, + dependencies ? [], + production ? true, + ... + } @ args: '' + if [ -d "${packageName}" ] + then + cd "${packageName}" + ${pinpointDependencies {inherit dependencies production;}} + cd .. + ${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."} + fi + ''; - var packageObj = JSON.parse(fs.readFileSync("package.json")); - - var lockObj = { - name: packageObj.name, - version: packageObj.version, - lockfileVersion: 2, - requires: true, - packages: { - "": { - name: packageObj.name, - version: packageObj.version, - license: packageObj.license, - bin: packageObj.bin, - dependencies: packageObj.dependencies, - engines: packageObj.engines, - optionalDependencies: packageObj.optionalDependencies - } - }, - dependencies: {} - }; - - function augmentPackageJSON(filePath, packages, dependencies) { - var packageJSON = path.join(filePath, "package.json"); - if(fs.existsSync(packageJSON)) { - var packageObj = JSON.parse(fs.readFileSync(packageJSON)); - packages[filePath] = { - version: packageObj.version, - integrity: "sha1-000000000000000000000000000=", - dependencies: packageObj.dependencies, - engines: packageObj.engines, - optionalDependencies: packageObj.optionalDependencies - }; - dependencies[packageObj.name] = { - version: packageObj.version, - integrity: "sha1-000000000000000000000000000=", - dependencies: {} - }; - processDependencies(path.join(filePath, "node_modules"), packages, dependencies[packageObj.name].dependencies); - } - } + # Extract the Node.js source code which is used to compile packages with + # native bindings + nodeSources = runCommand "node-sources" {} '' + tar --no-same-owner --no-same-permissions -xf ${nodejs.src} + mv node-* $out + ''; + + # Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty) + addIntegrityFieldsScript = writeTextFile { + name = "addintegrityfields.js"; + text = '' + var fs = require('fs'); + var path = require('path'); + + function augmentDependencies(baseDir, dependencies) { + for(var dependencyName in dependencies) { + var dependency = dependencies[dependencyName]; + + // Open package.json and augment metadata fields + var packageJSONDir = path.join(baseDir, "node_modules", dependencyName); + var packageJSONPath = path.join(packageJSONDir, "package.json"); + + if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored + console.log("Adding metadata fields to: "+packageJSONPath); + var packageObj = JSON.parse(fs.readFileSync(packageJSONPath)); + + if(dependency.integrity) { + packageObj["_integrity"] = dependency.integrity; + } else { + packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads. + } - function processDependencies(dir, packages, dependencies) { - if(fs.existsSync(dir)) { - var files = fs.readdirSync(dir); + if(dependency.resolved) { + packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided + } else { + packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories. + } - files.forEach(function(entry) { - var filePath = path.join(dir, entry); - var stats = fs.statSync(filePath); + if(dependency.from !== undefined) { // Adopt from property if one has been provided + packageObj["_from"] = dependency.from; + } - if(stats.isDirectory()) { - if(entry.substr(0, 1) == "@") { - // When we encounter a namespace folder, augment all packages belonging to the scope - var pkgFiles = fs.readdirSync(filePath); + fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2)); + } - pkgFiles.forEach(function(entry) { - if(stats.isDirectory()) { - var pkgFilePath = path.join(filePath, entry); - augmentPackageJSON(pkgFilePath, packages, dependencies); - } - }); - } else { - augmentPackageJSON(filePath, packages, dependencies); - } - } - }); - } - } + // Augment transitive dependencies + if(dependency.dependencies !== undefined) { + augmentDependencies(packageJSONDir, dependency.dependencies); + } + } + } - processDependencies("node_modules", lockObj.packages, lockObj.dependencies); + if(fs.existsSync("./package-lock.json")) { + var packageLock = JSON.parse(fs.readFileSync("./package-lock.json")); - fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2)); - ''; - }; + if(![1, 2].includes(packageLock.lockfileVersion)) { + process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n"); + process.exit(1); + } - # Script that links bins defined in package.json to the node_modules bin directory - # NPM does not do this for top-level packages itself anymore as of v7 - linkBinsScript = writeTextFile { - name = "linkbins.js"; - text = '' - var fs = require('fs'); - var path = require('path'); + if(packageLock.dependencies !== undefined) { + augmentDependencies(".", packageLock.dependencies); + } + } + ''; + }; + + # Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes + reconstructPackageLock = writeTextFile { + name = "reconstructpackagelock.js"; + text = '' + var fs = require('fs'); + var path = require('path'); + + var packageObj = JSON.parse(fs.readFileSync("package.json")); + + var lockObj = { + name: packageObj.name, + version: packageObj.version, + lockfileVersion: 2, + requires: true, + packages: { + "": { + name: packageObj.name, + version: packageObj.version, + license: packageObj.license, + bin: packageObj.bin, + dependencies: packageObj.dependencies, + engines: packageObj.engines, + optionalDependencies: packageObj.optionalDependencies + } + }, + dependencies: {} + }; - var packageObj = JSON.parse(fs.readFileSync("package.json")); + function augmentPackageJSON(filePath, packages, dependencies) { + var packageJSON = path.join(filePath, "package.json"); + if(fs.existsSync(packageJSON)) { + var packageObj = JSON.parse(fs.readFileSync(packageJSON)); + packages[filePath] = { + version: packageObj.version, + integrity: "sha1-000000000000000000000000000=", + dependencies: packageObj.dependencies, + engines: packageObj.engines, + optionalDependencies: packageObj.optionalDependencies + }; + dependencies[packageObj.name] = { + version: packageObj.version, + integrity: "sha1-000000000000000000000000000=", + dependencies: {} + }; + processDependencies(path.join(filePath, "node_modules"), packages, dependencies[packageObj.name].dependencies); + } + } - var nodeModules = Array(packageObj.name.split("/").length).fill("..").join(path.sep); + function processDependencies(dir, packages, dependencies) { + if(fs.existsSync(dir)) { + var files = fs.readdirSync(dir); - if(packageObj.bin !== undefined) { - fs.mkdirSync(path.join(nodeModules, ".bin")) + files.forEach(function(entry) { + var filePath = path.join(dir, entry); + var stats = fs.statSync(filePath); - if(typeof packageObj.bin == "object") { - Object.keys(packageObj.bin).forEach(function(exe) { - if(fs.existsSync(packageObj.bin[exe])) { - console.log("linking bin '" + exe + "'"); - fs.symlinkSync( - path.join("..", packageObj.name, packageObj.bin[exe]), - path.join(nodeModules, ".bin", exe) - ); - } - else { - console.log("skipping non-existent bin '" + exe + "'"); - } - }) - } - else { - if(fs.existsSync(packageObj.bin)) { - console.log("linking bin '" + packageObj.bin + "'"); - fs.symlinkSync( - path.join("..", packageObj.name, packageObj.bin), - path.join(nodeModules, ".bin", packageObj.name.split("/").pop()) - ); - } - else { - console.log("skipping non-existent bin '" + packageObj.bin + "'"); - } - } - } - else if(packageObj.directories !== undefined && packageObj.directories.bin !== undefined) { - fs.mkdirSync(path.join(nodeModules, ".bin")) - - fs.readdirSync(packageObj.directories.bin).forEach(function(exe) { - if(fs.existsSync(path.join(packageObj.directories.bin, exe))) { - console.log("linking bin '" + exe + "'"); - fs.symlinkSync( - path.join("..", packageObj.name, packageObj.directories.bin, exe), - path.join(nodeModules, ".bin", exe) - ); - } - else { - console.log("skipping non-existent bin '" + exe + "'"); - } - }) - } - ''; - }; + if(stats.isDirectory()) { + if(entry.substr(0, 1) == "@") { + // When we encounter a namespace folder, augment all packages belonging to the scope + var pkgFiles = fs.readdirSync(filePath); - prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}: - let - forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com"; - in - '' - # Pinpoint the versions of all dependencies to the ones that are actually being used - echo "pinpointing versions of dependencies..." - source $pinpointDependenciesScriptPath - - # Patch the shebangs of the bundled modules to prevent them from - # calling executables outside the Nix store as much as possible - patchShebangs . - - # Deploy the Node.js package by running npm install. Since the - # dependencies have been provided already by ourselves, it should not - # attempt to install them again, which is good, because we want to make - # it Nix's responsibility. If it needs to install any dependencies - # anyway (e.g. because the dependency parameters are - # incomplete/incorrect), it fails. - # - # The other responsibilities of NPM are kept -- version checks, build - # steps, postprocessing etc. - - export HOME=$TMPDIR - cd "${packageName}" - runHook preRebuild - - ${lib.optionalString bypassCache '' - ${lib.optionalString reconstructLock '' - if [ -f package-lock.json ] - then - echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!" - echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!" - rm package-lock.json - else - echo "No package-lock.json file found, reconstructing..." - fi + pkgFiles.forEach(function(entry) { + if(stats.isDirectory()) { + var pkgFilePath = path.join(filePath, entry); + augmentPackageJSON(pkgFilePath, packages, dependencies); + } + }); + } else { + augmentPackageJSON(filePath, packages, dependencies); + } + } + }); + } + } + + processDependencies("node_modules", lockObj.packages, lockObj.dependencies); + + fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2)); + ''; + }; + + # Script that links bins defined in package.json to the node_modules bin directory + # NPM does not do this for top-level packages itself anymore as of v7 + linkBinsScript = writeTextFile { + name = "linkbins.js"; + text = '' + var fs = require('fs'); + var path = require('path'); + + var packageObj = JSON.parse(fs.readFileSync("package.json")); + + var nodeModules = Array(packageObj.name.split("/").length).fill("..").join(path.sep); + + if(packageObj.bin !== undefined) { + fs.mkdirSync(path.join(nodeModules, ".bin")) + + if(typeof packageObj.bin == "object") { + Object.keys(packageObj.bin).forEach(function(exe) { + if(fs.existsSync(packageObj.bin[exe])) { + console.log("linking bin '" + exe + "'"); + fs.symlinkSync( + path.join("..", packageObj.name, packageObj.bin[exe]), + path.join(nodeModules, ".bin", exe) + ); + } + else { + console.log("skipping non-existent bin '" + exe + "'"); + } + }) + } + else { + if(fs.existsSync(packageObj.bin)) { + console.log("linking bin '" + packageObj.bin + "'"); + fs.symlinkSync( + path.join("..", packageObj.name, packageObj.bin), + path.join(nodeModules, ".bin", packageObj.name.split("/").pop()) + ); + } + else { + console.log("skipping non-existent bin '" + packageObj.bin + "'"); + } + } + } + else if(packageObj.directories !== undefined && packageObj.directories.bin !== undefined) { + fs.mkdirSync(path.join(nodeModules, ".bin")) + + fs.readdirSync(packageObj.directories.bin).forEach(function(exe) { + if(fs.existsSync(path.join(packageObj.directories.bin, exe))) { + console.log("linking bin '" + exe + "'"); + fs.symlinkSync( + path.join("..", packageObj.name, packageObj.directories.bin, exe), + path.join(nodeModules, ".bin", exe) + ); + } + else { + console.log("skipping non-existent bin '" + exe + "'"); + } + }) + } + ''; + }; + + prepareAndInvokeNPM = { + packageName, + bypassCache, + reconstructLock, + npmFlags, + production, + }: let + forceOfflineFlag = + if bypassCache + then "--offline" + else "--registry http://www.example.com"; + in '' + # Pinpoint the versions of all dependencies to the ones that are actually being used + echo "pinpointing versions of dependencies..." + source $pinpointDependenciesScriptPath + + # Patch the shebangs of the bundled modules to prevent them from + # calling executables outside the Nix store as much as possible + patchShebangs . + + # Deploy the Node.js package by running npm install. Since the + # dependencies have been provided already by ourselves, it should not + # attempt to install them again, which is good, because we want to make + # it Nix's responsibility. If it needs to install any dependencies + # anyway (e.g. because the dependency parameters are + # incomplete/incorrect), it fails. + # + # The other responsibilities of NPM are kept -- version checks, build + # steps, postprocessing etc. - node ${reconstructPackageLock} - ''} + export HOME=$TMPDIR + cd "${packageName}" + runHook preRebuild - node ${addIntegrityFieldsScript} + ${lib.optionalString bypassCache '' + ${lib.optionalString reconstructLock '' + if [ -f package-lock.json ] + then + echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!" + echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!" + rm package-lock.json + else + echo "No package-lock.json file found, reconstructing..." + fi + + node ${reconstructPackageLock} ''} - npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild + node ${addIntegrityFieldsScript} + ''} - runHook postRebuild + npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild - if [ "''${dontNpmInstall-}" != "1" ] - then - # NPM tries to download packages even when they already exist if npm-shrinkwrap is used. - rm -f npm-shrinkwrap.json + runHook postRebuild - npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install - fi + if [ "''${dontNpmInstall-}" != "1" ] + then + # NPM tries to download packages even when they already exist if npm-shrinkwrap is used. + rm -f npm-shrinkwrap.json - # Link executables defined in package.json - node ${linkBinsScript} - ''; + npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install + fi - # Builds and composes an NPM package including all its dependencies - buildNodePackage = - { name - , packageName - , version ? null - , dependencies ? [] - , buildInputs ? [] - , production ? true - , npmFlags ? "" - , dontNpmInstall ? false - , bypassCache ? false - , reconstructLock ? false - , preRebuild ? "" - , dontStrip ? true - , unpackPhase ? "true" - , buildPhase ? "true" - , meta ? {} - , ... }@args: - - let - extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ]; - in - stdenv.mkDerivation ({ - name = "${name}${if version == null then "" else "-${version}"}"; - buildInputs = [ tarWrapper python nodejs ] - ++ lib.optional (stdenv.isLinux) utillinux - ++ lib.optional (stdenv.isDarwin) libtool - ++ buildInputs; + # Link executables defined in package.json + node ${linkBinsScript} + ''; + + # Builds and composes an NPM package including all its dependencies + buildNodePackage = { + name, + packageName, + version ? null, + dependencies ? [], + buildInputs ? [], + production ? true, + npmFlags ? "", + dontNpmInstall ? false, + bypassCache ? false, + reconstructLock ? false, + preRebuild ? "", + dontStrip ? true, + unpackPhase ? "true", + buildPhase ? "true", + meta ? {}, + ... + } @ args: let + extraArgs = removeAttrs args ["name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta"]; + in + stdenv.mkDerivation ({ + name = "${name}${ + if version == null + then "" + else "-${version}" + }"; + buildInputs = + [tarWrapper python nodejs] + ++ lib.optional (stdenv.isLinux) utillinux + ++ lib.optional (stdenv.isDarwin) libtool + ++ buildInputs; inherit nodejs; @@ -511,7 +554,7 @@ let compositionScript = composePackage args; pinpointDependenciesScript = pinpointDependenciesOfPackage args; - passAsFile = [ "compositionScript" "pinpointDependenciesScript" ]; + passAsFile = ["compositionScript" "pinpointDependenciesScript"]; installPhase = '' source ${installPackage} @@ -523,7 +566,7 @@ let # Compose the package and all its dependencies source $compositionScriptPath - ${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }} + ${prepareAndInvokeNPM {inherit packageName bypassCache reconstructLock npmFlags production;}} # Create symlink to the deployed executable folder, if applicable if [ -d "$out/lib/node_modules/.bin" ] @@ -557,128 +600,139 @@ let runHook postInstall ''; - meta = { - # default to Node.js' platforms - platforms = nodejs.meta.platforms; - } // meta; - } // extraArgs); - - # Builds a node environment (a node_modules folder and a set of binaries) - buildNodeDependencies = - { name - , packageName - , version ? null - , src - , dependencies ? [] - , buildInputs ? [] - , production ? true - , npmFlags ? "" - , dontNpmInstall ? false - , bypassCache ? false - , reconstructLock ? false - , dontStrip ? true - , unpackPhase ? "true" - , buildPhase ? "true" - , ... }@args: - - let - extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ]; - in - stdenv.mkDerivation ({ - name = "node-dependencies-${name}${if version == null then "" else "-${version}"}"; - - buildInputs = [ tarWrapper python nodejs ] + meta = + { + # default to Node.js' platforms + platforms = nodejs.meta.platforms; + } + // meta; + } + // extraArgs); + + # Builds a node environment (a node_modules folder and a set of binaries) + buildNodeDependencies = { + name, + packageName, + version ? null, + src, + dependencies ? [], + buildInputs ? [], + production ? true, + npmFlags ? "", + dontNpmInstall ? false, + bypassCache ? false, + reconstructLock ? false, + dontStrip ? true, + unpackPhase ? "true", + buildPhase ? "true", + ... + } @ args: let + extraArgs = removeAttrs args ["name" "dependencies" "buildInputs"]; + in + stdenv.mkDerivation ({ + name = "node-dependencies-${name}${ + if version == null + then "" + else "-${version}" + }"; + + buildInputs = + [tarWrapper python nodejs] ++ lib.optional (stdenv.isLinux) utillinux ++ lib.optional (stdenv.isDarwin) libtool ++ buildInputs; - inherit dontStrip; # Stripping may fail a build for some package deployments - inherit dontNpmInstall unpackPhase buildPhase; - - includeScript = includeDependencies { inherit dependencies; }; - pinpointDependenciesScript = pinpointDependenciesOfPackage args; - - passAsFile = [ "includeScript" "pinpointDependenciesScript" ]; - - installPhase = '' - source ${installPackage} - - mkdir -p $out/${packageName} - cd $out/${packageName} - - source $includeScriptPath - - # Create fake package.json to make the npm commands work properly - cp ${src}/package.json . - chmod 644 package.json - ${lib.optionalString bypassCache '' - if [ -f ${src}/package-lock.json ] - then - cp ${src}/package-lock.json . - chmod 644 package-lock.json - fi - ''} - - # Go to the parent folder to make sure that all packages are pinpointed - cd .. - ${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."} - - ${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }} - - # Expose the executables that were installed - cd .. - ${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."} - - mv ${packageName} lib - ln -s $out/lib/node_modules/.bin $out/bin - ''; - } // extraArgs); - - # Builds a development shell - buildNodeShell = - { name - , packageName - , version ? null - , src - , dependencies ? [] - , buildInputs ? [] - , production ? true - , npmFlags ? "" - , dontNpmInstall ? false - , bypassCache ? false - , reconstructLock ? false - , dontStrip ? true - , unpackPhase ? "true" - , buildPhase ? "true" - , ... }@args: - - let - nodeDependencies = buildNodeDependencies args; - extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase" ]; - in - stdenv.mkDerivation ({ - name = "node-shell-${name}${if version == null then "" else "-${version}"}"; - - buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs; - buildCommand = '' - mkdir -p $out/bin - cat > $out/bin/shell < $out/bin/shell < $out/share/zsh/site-functions/_darwin-rebuild - #compdef darwin-rebuild - #autoload - _nix-common-options - local -a _1st_arguments - _1st_arguments=( - 'switch:Build, activate, and update the current generation'\ - 'build:Build without activating or updating the current generation'\ - 'check:Build and run the activation sanity checks'\ - 'changelog:Show most recent entries in the changelog'\ - ) - _arguments \ - '--list-generations[Print a list of all generations in the active profile]'\ - '--rollback[Roll back to the previous configuration]'\ - {--switch-generation,-G}'[Activate specified generation]'\ - '(--profile-name -p)'{--profile-name,-p}'[Profile to use to track current and previous system configurations]:Profile:_nix_profiles'\ - '1:: :->subcmds' && return 0 - case $state in - subcmds) - _describe -t commands 'darwin-rebuild subcommands' _1st_arguments - ;; - esac - EOF - ''; + darwin-zsh-completions = + super.runCommand "darwin-zsh-completions-0.0.0" { + preferLocalBuild = true; + } '' + mkdir -p $out/share/zsh/site-functions + cat <<-'EOF' > $out/share/zsh/site-functions/_darwin-rebuild + #compdef darwin-rebuild + #autoload + _nix-common-options + local -a _1st_arguments + _1st_arguments=( + 'switch:Build, activate, and update the current generation'\ + 'build:Build without activating or updating the current generation'\ + 'check:Build and run the activation sanity checks'\ + 'changelog:Show most recent entries in the changelog'\ + ) + _arguments \ + '--list-generations[Print a list of all generations in the active profile]'\ + '--rollback[Roll back to the previous configuration]'\ + {--switch-generation,-G}'[Activate specified generation]'\ + '(--profile-name -p)'{--profile-name,-p}'[Profile to use to track current and previous system configurations]:Profile:_nix_profiles'\ + '1:: :->subcmds' && return 0 + case $state in + subcmds) + _describe -t commands 'darwin-rebuild subcommands' _1st_arguments + ;; + esac + EOF + ''; }) ]; - home.packages = with pkgs; [ aspell aspellDicts.en darwin-zsh-completions ]; + home.packages = with pkgs; [aspell aspellDicts.en darwin-zsh-completions]; programs.emacs.package = pkgs.emacsMacport; diff --git a/user/settings/development/base.nix b/user/settings/development/base.nix index 64f52db9..d57680bd 100644 --- a/user/settings/development/base.nix +++ b/user/settings/development/base.nix @@ -1,31 +1,38 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { + home.packages = with pkgs; + [ + shellcheck + shfmt + editorconfig-core-c + python3Packages.yamllint + nodePackages.dockerfile-language-server-nodejs + nodePackages.yaml-language-server -{ home.packages = with pkgs; [ - shellcheck - shfmt - editorconfig-core-c - python3Packages.yamllint - nodePackages.dockerfile-language-server-nodejs - nodePackages.yaml-language-server + mosh - mosh + nix-prefetch-scripts + alejandra # nix formatter - nix-prefetch-scripts - alejandra # nix formatter - - httpie - jq - ] ++ ( - if !stdenv.isDarwin - then [ - httping - (lib.lowPrio firefox-devedition-bin) - ] else [ + httpie + jq ] - ); + ++ ( + if !stdenv.isDarwin + then [ + httping + (lib.lowPrio firefox-devedition-bin) + ] + else [ + ] + ); nixpkgs.overlays = [ (self: super: { - ripgrep = super.ripgrep.override { withPCRE2 = true; }; + ripgrep = super.ripgrep.override {withPCRE2 = true;}; }) ]; } diff --git a/user/settings/development/clojure.nix b/user/settings/development/clojure.nix index 0994ef19..7b06691a 100644 --- a/user/settings/development/clojure.nix +++ b/user/settings/development/clojure.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ clojure node2nixPackages.node-cljfmt diff --git a/user/settings/development/javascript.nix b/user/settings/development/javascript.nix index 232ad4ce..9b8bdabf 100644 --- a/user/settings/development/javascript.nix +++ b/user/settings/development/javascript.nix @@ -1,9 +1,10 @@ -{ config, pkgs, ... }: - -let - nodejs = pkgs.nodejs-18_x; -in { + config, + pkgs, + ... +}: let + nodejs = pkgs.nodejs-18_x; +in { nixpkgs.overlays = [ (self: super: { node2nixPackages = super.callPackage ../../packages/node2nix { @@ -11,37 +12,40 @@ in }; }) ]; - home.packages = (with pkgs; [ - nodejs - ] ++ ( - if stdenv.isDarwin - then - [ - ] - else - [ - # npm install may use any of these - binutils - gnumake - gcc - python2 - ] - )) ++ (with pkgs.nodePackages; [ - node2nix - nodemon - javascript-typescript-langserver - typescript-language-server - eslint_d - typescript + home.packages = + (with pkgs; + [ + nodejs + ] + ++ ( + if stdenv.isDarwin + then [ + ] + else [ + # npm install may use any of these + binutils + gnumake + gcc + python2 + ] + )) + ++ (with pkgs.nodePackages; [ + node2nix + nodemon + javascript-typescript-langserver + typescript-language-server + eslint_d + typescript - node-gyp - node-gyp-build - node-pre-gyp - ]) ++ (with pkgs.node2nixPackages; [ - pkgs.node2nixPackages."pnpm-7.12" + node-gyp + node-gyp-build + node-pre-gyp + ]) + ++ (with pkgs.node2nixPackages; [ + pkgs.node2nixPackages."pnpm-7.12" - pino-pretty - ]); + pino-pretty + ]); home.sessionVariables = { NO_UPDATE_NOTIFIER = "1"; # stop npm update-notifier diff --git a/user/settings/development/lisp.nix b/user/settings/development/lisp.nix index 9d591651..7a55c41c 100644 --- a/user/settings/development/lisp.nix +++ b/user/settings/development/lisp.nix @@ -1,6 +1,9 @@ -{ config, pkgs, ... }: - -{ home.packages = with pkgs; [ +{ + config, + pkgs, + ... +}: { + home.packages = with pkgs; [ ccl sbcl lispPackages.quicklisp diff --git a/user/settings/development/rust.nix b/user/settings/development/rust.nix index d45b1a19..63d0db35 100644 --- a/user/settings/development/rust.nix +++ b/user/settings/development/rust.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ cargo cargo-edit diff --git a/user/settings/development/web.nix b/user/settings/development/web.nix index f8b74adc..f1f45878 100644 --- a/user/settings/development/web.nix +++ b/user/settings/development/web.nix @@ -1,10 +1,15 @@ -{ config, pkgs, ... }: { - home.packages = with pkgs.nodePackages; [ - vscode-css-languageserver-bin - vscode-html-languageserver-bin - csslint - ] ++ [ - pkgs.nodePackages.stylelint - ]; + config, + pkgs, + ... +}: { + home.packages = with pkgs.nodePackages; + [ + vscode-css-languageserver-bin + vscode-html-languageserver-bin + csslint + ] + ++ [ + pkgs.nodePackages.stylelint + ]; } diff --git a/user/settings/dunst.nix b/user/settings/dunst.nix index 950c77a2..0232d47f 100644 --- a/user/settings/dunst.nix +++ b/user/settings/dunst.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { services.dunst = { enable = true; settings = { diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 32fb24af..f8eb5c19 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - -let +{ + config, + pkgs, + lib, + ... +}: let inherit (pkgs) stdenv; editorScript = pkgs.writeScriptBin "edit" '' @@ -29,15 +32,14 @@ let Keywords=Text;Editor; ''; }; -in -{ +in { imports = [ ../modules/eshell.nix ]; programs.emacs = { enable = true; - package = lib.mkDefault (pkgs.emacsNativeComp.override { withGTK3 = true; }); + package = lib.mkDefault (pkgs.emacsNativeComp.override {withGTK3 = true;}); eshell = { aliases = { pk = "eshell-up-pk $1"; @@ -66,120 +68,123 @@ in cdg = "cd (projectile-project-root)"; }; }; - extraPackages = epkgs: (with epkgs; [ - ace-link - all-the-icons - almost-mono-themes - add-node-modules-path - ag - all-the-icons - amx - auto-async-byte-compile - avy - bash-completion - caddyfile-mode - cider - clojure-mode - company - company-web - company-tabnine - consult - consult-eglot - counsel - counsel-projectile - crux - docker-compose-mode - dockerfile-mode - dired-git-info - editorconfig - eglot - eldoc-box - emmet-mode - esh-autosuggest - esh-buf-stack - esh-help - eshell-fringe-status - eshell-toggle - eshell-up - evil - evil-anzu - evil-collection - evil-commentary - evil-embrace - evil-ledger - evil-matchit - evil-mu4e - evil-numbers - evil-org - evil-quickscope - evil-space - evil-surround - eyebrowse - feature-mode - format-all - flycheck - flyspell-correct - general - git-gutter-fringe - git-messenger - git-modes - git-timemachine - gitlab-ci-mode - gitlab-ci-mode-flycheck - go-mode - goto-chg - haskell-mode - helpful - ivy-hydra - janet-mode - jinja2-mode - js2-mode - json-mode - k8s-mode - kubel - kubel-evil - ledger-mode - magit - markdown-mode - modus-themes - doom-modeline - nginx-mode - nix-mode - nix-update - org-journal - paredit - php-mode - posframe - projectile - projectile-ripgrep - quickrun - racket-mode - rainbow-mode - rainbow-delimiters - restclient - ripgrep - rjsx-mode - rustic - scss-mode - spacemacs-theme - swiper - tide - toml-mode - tree-sitter - tree-sitter-langs - tree-sitter-indent - typescript-mode - undo-tree - use-package - web-mode - wgrep-ag - ws-butler - which-key - yaml-mode - yasnippet - ] ++ lib.optionals (!stdenv.isDarwin) [ - pkgs.mu - ]); + extraPackages = epkgs: (with epkgs; + [ + ace-link + all-the-icons + almost-mono-themes + add-node-modules-path + ag + all-the-icons + amx + apheleia + auto-async-byte-compile + avy + bash-completion + caddyfile-mode + cider + clojure-mode + company + company-web + company-tabnine + consult + consult-eglot + counsel + counsel-projectile + crux + docker-compose-mode + dockerfile-mode + dired-git-info + editorconfig + eglot + eldoc-box + emmet-mode + esh-autosuggest + esh-buf-stack + esh-help + eshell-fringe-status + eshell-toggle + eshell-up + evil + evil-anzu + evil-collection + evil-commentary + evil-embrace + evil-ledger + evil-matchit + evil-mu4e + evil-numbers + evil-org + evil-quickscope + evil-space + evil-surround + eyebrowse + feature-mode + format-all + flycheck + flyspell-correct + general + git-gutter-fringe + git-messenger + git-modes + git-timemachine + gitlab-ci-mode + gitlab-ci-mode-flycheck + go-mode + goto-chg + haskell-mode + helpful + ivy-hydra + janet-mode + jinja2-mode + js2-mode + json-mode + k8s-mode + kubel + kubel-evil + ledger-mode + magit + markdown-mode + modus-themes + doom-modeline + nginx-mode + nix-mode + nix-update + org-journal + paredit + php-mode + posframe + projectile + projectile-ripgrep + quickrun + racket-mode + rainbow-mode + rainbow-delimiters + restclient + ripgrep + rjsx-mode + rustic + scss-mode + spacemacs-theme + swiper + tide + toml-mode + tree-sitter + tree-sitter-langs + tree-sitter-indent + typescript-mode + undo-tree + use-package + web-mode + wgrep-ag + ws-butler + which-key + yaml-mode + yasnippet + ] + ++ lib.optionals (!stdenv.isDarwin) [ + pkgs.mu + ]); }; home.packages = [ editorScript @@ -191,7 +196,7 @@ in source = ../emacs/early-init.el; onChange = '' ${config.programs.emacs.finalPackage}/bin/emacs -Q -batch -f batch-byte-compile .config/emacs/early-init.el - ''; + ''; }; xdg.configFile."emacs/init.el" = { source = ../emacs/init.el; diff --git a/user/settings/gaming.nix b/user/settings/gaming.nix index 4132bba1..fb732904 100644 --- a/user/settings/gaming.nix +++ b/user/settings/gaming.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ steam wineWowPackages.stable diff --git a/user/settings/git.nix b/user/settings/git.nix index f52f198d..7a0c35da 100644 --- a/user/settings/git.nix +++ b/user/settings/git.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ gitAndTools.git-extras ]; diff --git a/user/settings/gnupg.nix b/user/settings/gnupg.nix index 86480aee..7f96223c 100644 --- a/user/settings/gnupg.nix +++ b/user/settings/gnupg.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.file.".gnupg" = { recursive = true; source = ../gnupg; diff --git a/user/settings/golang.nix b/user/settings/golang.nix index 4cc59343..92abbf4d 100644 --- a/user/settings/golang.nix +++ b/user/settings/golang.nix @@ -1,10 +1,12 @@ -{ config, pkgs, ... }: - { - home.packages = (with pkgs; [ + config, + pkgs, + ... +}: { + home.packages = with pkgs; [ go go-langserver goimports gotools - ]); + ]; } diff --git a/user/settings/i3.nix b/user/settings/i3.nix index cb71baf3..5443d1d6 100644 --- a/user/settings/i3.nix +++ b/user/settings/i3.nix @@ -1,6 +1,9 @@ -{ config, pkgs, lib, ... }: - { + config, + pkgs, + lib, + ... +}: { xdg.configFile.i3status = { recursive = true; source = ../i3/i3status; @@ -9,32 +12,58 @@ mod = "Mod4"; mode_system = "System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown"; locker = "${pkgs.xautolock}/bin/xautolock -locknow"; - in - { + in { enable = true; config = { modifier = mod; assigns = { - "1" = [{ class = "^Ripcord$"; }]; - "3" = [{ class = "^Firefox Developer Edition$"; }]; - "8" = [{ class = "^Emacs$"; }]; - "9" = [{ class = "\.exe$"; }]; - "10" = [{ class = "^Barrier$"; }]; + "1" = [{class = "^Ripcord$";}]; + "3" = [{class = "^Firefox Developer Edition$";}]; + "8" = [{class = "^Emacs$";}]; + "9" = [{class = "\.exe$";}]; + "10" = [{class = "^Barrier$";}]; }; floating = { criteria = [ - { class = "Pinentry$"; } + {class = "Pinentry$";} # https://github.com/ValveSoftware/steam-for-linux/issues/1040 - { class = "^Steam$"; title = "^Friends$"; } - { class = "^Steam$"; title = "Steam - News"; } - { class = "^Steam$"; title = ".* - Chat"; } - { class = "^Steam$"; title = "^Settings$"; } - { class = "^Steam$"; title = ".* - event started"; } - { class = "^Steam$"; title = ".* CD key"; } - { class = "^Steam$"; title = "^Steam - Self Updater$"; } - { class = "^Steam$"; title = "^Screenshot Uploader$"; } - { class = "^Steam$"; title = "^Steam Guard - Computer Authorization Required$"; } - { title = "^Steam Keyboard$"; } + { + class = "^Steam$"; + title = "^Friends$"; + } + { + class = "^Steam$"; + title = "Steam - News"; + } + { + class = "^Steam$"; + title = ".* - Chat"; + } + { + class = "^Steam$"; + title = "^Settings$"; + } + { + class = "^Steam$"; + title = ".* - event started"; + } + { + class = "^Steam$"; + title = ".* CD key"; + } + { + class = "^Steam$"; + title = "^Steam - Self Updater$"; + } + { + class = "^Steam$"; + title = "^Screenshot Uploader$"; + } + { + class = "^Steam$"; + title = "^Steam Guard - Computer Authorization Required$"; + } + {title = "^Steam Keyboard$";} ]; }; window = { @@ -85,7 +114,6 @@ "${mod}+Shift+9" = "move container to workspace 9"; "${mod}+Shift+0" = "move container to workspace 10"; - # move workspace "${mod}+Mod1+h" = "move workspace to output left"; "${mod}+Mod1+j" = "move workspace to output down"; diff --git a/user/settings/ledger.nix b/user/settings/ledger.nix index 61d3df7e..6c674ff9 100644 --- a/user/settings/ledger.nix +++ b/user/settings/ledger.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.file.".ledgerrc".text = '' --date-format %F --start-of-week 1 diff --git a/user/settings/mail.nix b/user/settings/mail.nix index 59fdc7d2..b3f288fb 100644 --- a/user/settings/mail.nix +++ b/user/settings/mail.nix @@ -1,6 +1,9 @@ -{ config, lib, pkgs, ... }: - { + config, + lib, + pkgs, + ... +}: { home.packages = [ pkgs.html2text ]; diff --git a/user/settings/music-management.nix b/user/settings/music-management.nix index 6dd1f12e..6f42eb35 100644 --- a/user/settings/music-management.nix +++ b/user/settings/music-management.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ beets ]; diff --git a/user/settings/music.nix b/user/settings/music.nix index 5120bd19..e7b80ce2 100644 --- a/user/settings/music.nix +++ b/user/settings/music.nix @@ -1,18 +1,20 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ cmus playerctl sonixd - (tauon.override { withDiscordRPC = true; }) + (tauon.override {withDiscordRPC = true;}) ]; xdg.desktopEntries.sonixd = { name = "sonixd"; exec = "sonixd"; comment = "Sonixd Music Player"; - categories = [ "Audio" "AudioVideo" ]; + categories = ["Audio" "AudioVideo"]; genericName = "Music Player"; }; } diff --git a/user/settings/nix.nix b/user/settings/nix.nix index 8e4bf513..f7f0a44c 100644 --- a/user/settings/nix.nix +++ b/user/settings/nix.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { nixpkgs.config = import ../config.nix; nixpkgs.overlays = [ (import ../overlays/extra-packages.nix) diff --git a/user/settings/nixos.nix b/user/settings/nixos.nix index de386db3..50e38e89 100644 --- a/user/settings/nixos.nix +++ b/user/settings/nixos.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { imports = [ ./nix.nix ./nixpkgs.nix diff --git a/user/settings/nixpkgs.nix b/user/settings/nixpkgs.nix index 9f939c33..ee993bd5 100644 --- a/user/settings/nixpkgs.nix +++ b/user/settings/nixpkgs.nix @@ -1,17 +1,18 @@ -{ config, pkgs, ... }: - -let +{ + config, + pkgs, + ... +}: let inherit (pkgs) stdenv; stableConfig = config.nixpkgs.config; -in -{ +in { imports = [ ./nix.nix ]; nixpkgs.overlays = [ (self: super: { - firefox-bin-unwrapped = super.firefox-bin-unwrapped.override { systemLocale = "en-GB"; }; - firefox-devedition-bin-unwrapped = super.firefox-devedition-bin-unwrapped.override { systemLocale = "en-GB"; }; + firefox-bin-unwrapped = super.firefox-bin-unwrapped.override {systemLocale = "en-GB";}; + firefox-devedition-bin-unwrapped = super.firefox-devedition-bin-unwrapped.override {systemLocale = "en-GB";}; }) ]; } diff --git a/user/settings/passwords.nix b/user/settings/passwords.nix index 909c9633..ff78281c 100644 --- a/user/settings/passwords.nix +++ b/user/settings/passwords.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.packages = with pkgs; [ keepassxc pwgen diff --git a/user/settings/rofi.nix b/user/settings/rofi.nix index 4c932224..d62ea7cf 100644 --- a/user/settings/rofi.nix +++ b/user/settings/rofi.nix @@ -1,6 +1,9 @@ -{ config, lib, pkgs, ... }: - { + config, + lib, + pkgs, + ... +}: { xdg.configFile."networkmanager-dmenu/config.ini".text = '' [dmenu] dmenu_command = ${pkgs.rofi}/bin/dmenu @@ -12,7 +15,7 @@ nixpkgs.overlays = [ (self: super: { - rofi= super.rofi.overrideAttrs (oldAttrs: rec { + rofi = super.rofi.overrideAttrs (oldAttrs: rec { postInstall = '' ln $out/bin/rofi $out/bin/dmenu ''; diff --git a/user/settings/satoshipay.nix b/user/settings/satoshipay.nix index 4e96a227..2ecb4761 100644 --- a/user/settings/satoshipay.nix +++ b/user/settings/satoshipay.nix @@ -1,12 +1,14 @@ -{ config, lib, pkgs, ... }: - -let +{ + config, + lib, + pkgs, + ... +}: let inherit (pkgs) stdenv; spGitConfig = { user.email = "alan@satoshipay.io"; }; -in -{ +in { imports = [ ./development/javascript.nix ./development/web.nix @@ -16,32 +18,33 @@ in KUBECTX_IGNORE_FZF = "1"; }; home.packages = with pkgs; ([ - caddy - openssl - mongodb-tools - pgcli - pgformatter - postgresql - s3cmd - sops + caddy + openssl + mongodb-tools + pgcli + pgformatter + postgresql + s3cmd + sops - lumen + lumen - mkcert - google-cloud-sdk - doctl - kubectl - kubetail - kubectx - kubernetes-helm - helmfile - ] ++ (lib.optionals (!stdenv.isDarwin) - [ - docker-compose + mkcert + google-cloud-sdk + doctl + kubectl + kubetail + kubectx + kubernetes-helm + helmfile + ] + ++ (lib.optionals (!stdenv.isDarwin) + [ + docker-compose - ripcord - robo3t - ])); + ripcord + robo3t + ])); programs.git.includes = [ { @@ -84,8 +87,7 @@ in accounts.email.accounts.satoshipay = let address = "alan@satoshipay.io"; - in - { + in { inherit address; primary = lib.mkDefault true; realName = "Alan Pearce"; diff --git a/user/settings/ssh.nix b/user/settings/ssh.nix index 0c8300eb..0ccc9796 100644 --- a/user/settings/ssh.nix +++ b/user/settings/ssh.nix @@ -1,6 +1,9 @@ -{ config, lib, pkgs, ... }: - { + config, + lib, + pkgs, + ... +}: { programs.ssh = { enable = true; compression = true; diff --git a/user/settings/sxhkd.nix b/user/settings/sxhkd.nix index a30db28a..cc21264b 100644 --- a/user/settings/sxhkd.nix +++ b/user/settings/sxhkd.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { xdg.configFile."sxhkd/sxhkdrc".text = '' XF86AudioMute pamixer --toggle-mute diff --git a/user/settings/tabnine.nix b/user/settings/tabnine.nix index dab2273b..61cbf29c 100644 --- a/user/settings/tabnine.nix +++ b/user/settings/tabnine.nix @@ -1,7 +1,9 @@ -{ config, pkgs, ... }: - { - imports = [ ../modules/tabnine.nix ]; + config, + pkgs, + ... +}: { + imports = [../modules/tabnine.nix]; home.packages = with pkgs; [ tabnine ]; @@ -26,7 +28,7 @@ tabnine_cloud_certificate_domain = null; tabnine_cloud_host = null; tabnine_cloud_port = null; - cloud_whitelist = [ ]; + cloud_whitelist = []; api_key = null; api_key_service_level = null; api_base_url = null; @@ -44,40 +46,41 @@ lspConfig = { "language.typescript" = { command = "typescript-language-server"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.javascript" = { command = "javascript-typescript-stdio"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.css" = { command = "css-languageserver"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.scss" = { command = "css-languageserver"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.html" = { command = "html-languageserver"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.dockerfile" = { command = "docker-langserver"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.yaml" = { command = "yaml-language-server"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.haskell" = { command = "hie"; - args = [ "--stdio" ]; + args = ["--stdio"]; }; "language.go" = { command = "go-langserver"; args = [ - "-mode" "stdio" + "-mode" + "stdio" "-gocodecompletion" ]; }; diff --git a/user/settings/trezor.nix b/user/settings/trezor.nix index a4f3ba75..3211bb42 100644 --- a/user/settings/trezor.nix +++ b/user/settings/trezor.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.file.".ssh/agent.config" = { text = '' ecdsa-curve-name = ed25519 diff --git a/user/settings/user-interface.nix b/user/settings/user-interface.nix index f0e4c798..af432a91 100644 --- a/user/settings/user-interface.nix +++ b/user/settings/user-interface.nix @@ -1,28 +1,31 @@ -{ config, pkgs, ... }: - -let - inherit (pkgs) stdenv; -in { + config, + pkgs, + ... +}: let + inherit (pkgs) stdenv; +in { home.sessionVariables = { TERMINAL = "xterm"; }; programs.keychain = { enable = true; - extraFlags = [ "--quiet" "--systemd" ]; - keys = [ ]; + extraFlags = ["--quiet" "--systemd"]; + keys = []; }; nixpkgs.config.librewolf = { enablePlasmaBrowserIntegration = true; }; - home.packages = with pkgs; [ - librewolf - logseq - ] ++ lib.optionals (!stdenv.isDarwin) (with pkgs; [ - falkon - mu - signal-desktop - ]); + home.packages = with pkgs; + [ + librewolf + logseq + ] + ++ lib.optionals (!stdenv.isDarwin) (with pkgs; [ + falkon + mu + signal-desktop + ]); } diff --git a/user/settings/xresources.nix b/user/settings/xresources.nix index 5ab0bb49..3481962d 100644 --- a/user/settings/xresources.nix +++ b/user/settings/xresources.nix @@ -1,6 +1,8 @@ -{ config, pkgs, ... }: - { + config, + pkgs, + ... +}: { home.file.".xresources" = { recursive = true; source = ../xresources; diff --git a/user/settings/zsh.nix b/user/settings/zsh.nix index 6e6c04d3..2a30bc63 100644 --- a/user/settings/zsh.nix +++ b/user/settings/zsh.nix @@ -1,16 +1,25 @@ -{ config, lib, pkgs, ... }: - -let +{ + config, + lib, + pkgs, + ... +}: let inherit (pkgs) stdenv; - lsOptions = if stdenv.isDarwin then "-p" else "-v --group-directories-first"; - lsIsoDate = if stdenv.isDarwin then "" else "--time-style=long-iso"; + lsOptions = + if stdenv.isDarwin + then "-p" + else "-v --group-directories-first"; + lsIsoDate = + if stdenv.isDarwin + then "" + else "--time-style=long-iso"; zshrc = ".config/zsh/.zshrc"; mkZshPlugin = attrs: { name = attrs.name; src = stdenv.mkDerivation { inherit (attrs) src; name = "zsh-plugin-${attrs.name}"; - buildInputs = [ pkgs.zsh ]; + buildInputs = [pkgs.zsh]; buildPhase = '' zsh -c 'for f in **/*.zsh; zcompile "$f"' ''; @@ -19,8 +28,7 @@ let ''; }; }; -in -{ +in { home.packages = with pkgs; [ fzf ghq @@ -52,7 +60,7 @@ in ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=8"; }; - plugins = (map mkZshPlugin [ + plugins = map mkZshPlugin [ { name = "cd-gitroot"; src = pkgs.fetchFromGitHub { @@ -93,7 +101,7 @@ in sha256 = "0qmm0xm1aiy3fnn2vib26z10cfy707yqg0vg5236r7978glswdlg"; }; } - ]); + ]; shellAliases = { l = "ls ${lsOptions} -Bp"; @@ -111,10 +119,8 @@ in https = "http --default-scheme https"; history = "fc -l $(( $LINES - 2 ))"; - hist-freq-lines = - "fc -l -10000 | cut -d' ' -f4- | sort | uniq -c | sort -g | tail -n100 | less"; - hist-freq-commands = - "fc -l -10000 | cut -d' ' -f4 | sort | uniq -c | sort -g | tail -n10 | less"; + hist-freq-lines = "fc -l -10000 | cut -d' ' -f4- | sort | uniq -c | sort -g | tail -n100 | less"; + hist-freq-commands = "fc -l -10000 | cut -d' ' -f4 | sort | uniq -c | sort -g | tail -n10 | less"; wprop = "xprop | egrep '^WM_(CLASS|NAME|WINDOW_ROLE|TYPE)'"; # Enable the following commands to support aliases. @@ -213,26 +219,28 @@ in fi ''; - initExtra = '' - autoload -Uz compinit - compinit -C - typeset -T GHQ_ROOT ghq_root - export GHQ_ROOT="$HOME/projects" - - function hist-freq-subcommands () { - fc -l -m "$1*" -10000 | cut -d' ' -f4- | sort | uniq -c | sort -g | tail -n100 | less - } - - source ${pkgs.fzf}/share/fzf/key-bindings.zsh - source ${pkgs.fzf}/share/fzf/completion.zsh - - '' + builtins.readFile ../zsh/zshrc + ( - if stdenv.isDarwin - then builtins.readFile ../zsh/zshrc.darwin - else "" - ); + initExtra = + '' + autoload -Uz compinit + compinit -C + typeset -T GHQ_ROOT ghq_root + export GHQ_ROOT="$HOME/projects" + + function hist-freq-subcommands () { + fc -l -m "$1*" -10000 | cut -d' ' -f4- | sort | uniq -c | sort -g | tail -n100 | less + } + + source ${pkgs.fzf}/share/fzf/key-bindings.zsh + source ${pkgs.fzf}/share/fzf/completion.zsh + + '' + + builtins.readFile ../zsh/zshrc + + ( + if stdenv.isDarwin + then builtins.readFile ../zsh/zshrc.darwin + else "" + ); }; - home.file."${zshrc}".onChange = - "${pkgs.zsh}/bin/zsh -i -c 'autoload -Uz compinit && compinit && zcompile ${zshrc}'"; + home.file."${zshrc}".onChange = "${pkgs.zsh}/bin/zsh -i -c 'autoload -Uz compinit && compinit && zcompile ${zshrc}'"; } -- cgit 1.4.1