diff --git a/alacritty.nix b/alacritty.nix deleted file mode 100644 index 7fad0a4..0000000 --- a/alacritty.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ pkgs, config, ... }: - -{ - home-manager.users."riley" = { - programs.alacritty = { - enable = true; - settings = { - - window.padding = { x = 8; y = 8; }; - - font = { - normal = { family = "Fira Code"; style = "Regular"; }; - bold = { family = "Fira Code"; style = "Medium"; }; - }; - - colors = let theme = (import ./colors.nix)."dark"; in { - - primary = { - background = "#" + theme.background.primary; - foreground = "#" + theme.foreground.primary; - }; - - normal = { - red = "#" + theme.red.normal; - blue = "#" + theme.blue.normal; - magenta = "#" + theme.purple.normal; - }; - - bright = { - red = "#" + theme.red.bright; - blue = "#" + theme.blue.bright; - magenta = "#" + theme.purple.bright; - }; - }; - }; - - }; - }; -} diff --git a/colors.nix b/colors.nix index 737d34f..e7b6bce 100644 --- a/colors.nix +++ b/colors.nix @@ -1,6 +1,6 @@ # Color schemes. -{ +let inherit (builtins) mapAttrs map; in rec { # A simple dark theme with vibrant colors. "dark" = rec { @@ -57,45 +57,63 @@ red = { normal = "ff6161"; bright = "ff3b3b"; - pastel = "ff8787"; + pastel = "ff5369"; }; green = { - normal = ""; - bright = ""; + bright = "29f26c"; + normal = "8aff80"; pastel = ""; }; blue = { - normal = "3eafff"; - bright = "30c7ff"; + normal = "30c7ff"; + bright = "00e1ff"; pastel = ""; }; yellow = { - normal = ""; - bright = ""; + normal = "fcfc51"; + bright = "fcfc51"; pastel = ""; }; purple = { normal = "bd78fa"; - bright = "dda1ff"; - pastel = ""; + bright = "c97ffa"; + pastel = "00e1ff"; }; cyan = { - normal = ""; - bright = ""; + normal = "29f8ff"; + bright = "26e3fc"; + pastel = ""; + }; + + pink = { + normal = "f74ddb"; + bright = "ff63e5"; pastel = ""; }; orange = { - normal = ""; - bright = ""; + normal = "ff5e69"; + bright = "fca151"; pastel = ""; }; + misc = { + blueGrey = "9ccdd9"; + teal = "00ccad"; + lime = "d5ff63"; + }; + + hex = mapAttrs (name: value: + if name != "grayscales" + then mapAttrs (n: v: "#" + v) value + else map (v: "#" + v) value + ) (dark); + }; } diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 88b6795..0000000 --- a/configuration.nix +++ /dev/null @@ -1,128 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: - -{ - imports = [ - - # Home-manager modules - - - ./hardware-configuration.nix - - # Programs - ./kakoune.nix - ./alacritty.nix - ./git.nix - - # Display server and related config - ./display.nix - ./fonts.nix - - ]; - - nixpkgs.config.allowUnfree = true; - nix.autoOptimiseStore = true; - nix.gc.automatic = true; - - boot = { - loader.systemd-boot = { - enable = true; - editor = false; - configurationLimit = 10; - }; - loader.efi.canTouchEfiVariables = true; - cleanTmpDir = true; - }; - - networking.hostName = "thor"; - - # Set your time zone. - time.timeZone = "Europe/Amsterdam"; - - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # Per-interface useDHCP will be mandatory in the future, so this generated config - # replicates the default behaviour. - networking.useDHCP = false; - networking.interfaces.enp9s0.useDHCP = true; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # }; - - # Enable CUPS to print documents. - # services.printing.enable = true; - - # Enable sound. - sound.enable = true; - hardware.pulseaudio.enable = true; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users."riley" = { - isNormalUser = true; - extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - }; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - - # Some utils - - wget - curl - git - - # Modern coreutils - - ripgrep - bottom - skim - exa - bat - lf - fd - - ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "21.11"; # Did you read the comment? - -} - diff --git a/configuration.nix.old b/configuration.nix.old new file mode 100644 index 0000000..23f7a71 --- /dev/null +++ b/configuration.nix.old @@ -0,0 +1,87 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + config = { + imports = [ + + # Home-manager modules + + + ./hardware-configuration.nix + + # Programs + ./modules/kakoune + ./alacritty.nix + ./git.nix + + # Display server and related config + ./display.nix + ./fonts.nix + + ]; + + nixpkgs.config.allowUnfree = true; + nix.autoOptimiseStore = true; + nix.gc.automatic = true; + + boot = { + loader.systemd-boot = { + enable = true; + editor = false; + configurationLimit = 10; + }; + loader.efi.canTouchEfiVariables = true; + cleanTmpDir = true; + }; + + networking.hostName = "thor"; + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + networking.useDHCP = false; + networking.interfaces.enp9s0.useDHCP = true; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users."riley" = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + environment.systemPackages = with pkgs; [ + + # Some utils + + wget + curl + git + + # Modern coreutils + + ripgrep + bottom + skim + exa + bat + lf + fd + + ]; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.11"; # Did you read the comment? + + }; +} diff --git a/kakoune.nix b/kakoune.nix deleted file mode 100644 index 7ddb17c..0000000 --- a/kakoune.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ lib, pkgs, ... }: - -let kakrc = pkgs.writeTextFile (rec { - name = "kakrc.kak"; - destination = "/share/kak/autoload/${name}"; - text = '' - add-highlighter global/ number-lines -separator ' │ ' -hlcursor - set-option global tabstop 4 - set global ui_options ncurses_assistant=cat - map global normal :buffer-next - eval %sh{ kak-lsp --kakoune -s $kak_session } - ''; - }); - theme = let x = (import ./colors.nix)."dark"; in pkgs.writeTextFile (rec { - name = "theme.kak"; - destination = "/share/kak/autoload/${name}"; - text = '' - face global LineNumbers rgb:${x.background.slight} - face global BufferPadding rgb:${x.background.slight} - face global LineNumberCursor rgb:${x.foreground.primary} - face global crosshairs_line "default,rgb:${x.background.normal}" - face global MenuForeground "default,blue" - face global MenuBackground "default,rgb:313131" - face global InlayHint rgb:828282 - - face global comment rgb:${x.background.slight} - ''; - }); -in { - environment.systemPackages = with pkgs; [ - (pkgs.kakoune.override { - plugins = with kakounePlugins; [ - - # Custom config - kakrc - theme - - # Kakoune language server support - kak-lsp - - ]; - }) - rnix-lsp - ]; -} diff --git a/machines/thor/configuration.nix b/machines/thor/configuration.nix new file mode 100644 index 0000000..b23db53 --- /dev/null +++ b/machines/thor/configuration.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./hardware-configuration.nix + ../../modules + ]; + + riley = { + ide = true; + gui = true; + }; + + networking = { + hostName = "thor"; + interfaces.enp9s0.useDHCP = true; + }; +} diff --git a/hardware-configuration.nix b/machines/thor/hardware-configuration.nix similarity index 100% rename from hardware-configuration.nix rename to machines/thor/hardware-configuration.nix diff --git a/modules/alacritty.nix b/modules/alacritty.nix new file mode 100644 index 0000000..ee5604e --- /dev/null +++ b/modules/alacritty.nix @@ -0,0 +1,45 @@ +{ pkgs, config, ... }: + +{ + home-manager.users."riley" = { + programs.alacritty = { + enable = true; + settings = { + + window.padding = { x = 8; y = 8; }; + + font = { + normal = { family = "Fira Code"; style = "Regular"; }; + bold = { family = "Fira Code"; style = "Medium"; }; + }; + + colors = with (import ../colors.nix)."dark".hex; { + + primary = { + background = background.primary; + foreground = foreground.primary; + }; + + normal = { + red = red.normal; + green = green.normal; + blue = blue.normal; + magenta = purple.normal; + yellow = yellow.normal; + cyan = cyan.normal; + }; + + bright = { + red = red.bright; + green = green.bright; + blue = blue.bright; + magenta = purple.bright; + yellow = yellow.bright; + cyan = cyan.bright; + }; + }; + }; + + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..7b74a12 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,90 @@ +# Global config + +{ config, lib, pkgs, ... }: + +{ + + options.riley = with lib; { + + ide = mkOption { + type = types.bool; + description = '' + Enable IDE-like plugins such as language servers for Rust, Haskell and + Nix in the editor, and configure accordingly. + ''; + default = true; + }; + + gui = mkOption { + type = types.bool; + description = '' + Enables GUI applications, a display server, audio server and related services. + ''; + default = true; + }; + + }; + + imports = [ + + + + ./kakoune + ./display + + ./alacritty.nix + ./fonts.nix + ./git.nix + + ]; + + config = { + + environment.systemPackages = with pkgs; [ + + # Web utils + + wget + curl + git + + # Coreutils + + ripgrep + bottom + skim + exa + bat + lf + fd + + ]; + + boot = { + loader.systemd-boot = { + enable = true; + editor = false; + configurationLimit = 10; + }; + + loader.efi = { + canTouchEfiVariables = true; + }; + + cleanTmpDir = true; + }; + + networking = { + firewall.enable = false; + useDHCP = false; + }; + + nixpkgs.config.allowUnfree = true; + + users.users."riley" = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + }; + + }; +} diff --git a/display.nix b/modules/display/default.nix similarity index 94% rename from display.nix rename to modules/display/default.nix index e9f4995..4568bd7 100644 --- a/display.nix +++ b/modules/display/default.nix @@ -1,7 +1,6 @@ { pkgs, config, lib, ... }: -let theme = (import ./colors.nix)."dark"; - hex = (c: "#${c}"); +let theme = (import ../../colors.nix)."dark".hex; # Keybinds that launch an application. launchers = ({ browser }: mod: { @@ -156,15 +155,15 @@ let theme = (import ./colors.nix)."dark"; colors = { focused = rec { - background = hex (theme.background.normal); - text = hex (theme."red".bright); + background = theme.background.normal; + text = theme."red".bright; border = background; childBorder = border; indicator = border; }; unfocused = rec { - background = hex (theme.background.normal); - text = hex (theme.foreground.slight); + background = theme.background.normal; + text = theme.foreground.slight; border = background; childBorder = border; indicator = border; diff --git a/fonts.nix b/modules/fonts.nix similarity index 100% rename from fonts.nix rename to modules/fonts.nix diff --git a/git.nix b/modules/git.nix similarity index 100% rename from git.nix rename to modules/git.nix diff --git a/modules/kakoune/colors/common.nix b/modules/kakoune/colors/common.nix new file mode 100644 index 0000000..9633e89 --- /dev/null +++ b/modules/kakoune/colors/common.nix @@ -0,0 +1,19 @@ +# Haskell text faces and other stuff related to syntax highlighting +# for Haskell in Kakoune, because I prefer different color arrangements +# per language. + +{ theme, pkgs, ... }: pkgs.writeTextFile (rec { + name = "common.kak"; + destination = "/share/kak/colors/${name}"; + text = with theme; '' + face global value rgb:${yellow.bright} + face global string rgb:${green.normal} + face global variable +a + face global module rgb:${green.normal} + face global operator rgb:${cyan.bright} + face global type rgb:${yellow.normal} + face global function rgb:${cyan.bright} + face global keyword rgb:${blue.normal}+b + face global builtin +b + ''; +}) diff --git a/modules/kakoune/colors/default.nix b/modules/kakoune/colors/default.nix new file mode 100644 index 0000000..3ef790e --- /dev/null +++ b/modules/kakoune/colors/default.nix @@ -0,0 +1,8 @@ +# Import syntax themes + +{ lib, theme, pkgs, ... }: [ + (import ./haskell.nix { inherit lib theme pkgs; }) + (import ./rust.nix { inherit lib theme pkgs; }) + (import ./nix.nix { inherit lib theme pkgs; }) + (import ./common.nix { inherit lib theme pkgs; }) +] diff --git a/modules/kakoune/colors/haskell.nix b/modules/kakoune/colors/haskell.nix new file mode 100644 index 0000000..f21739d --- /dev/null +++ b/modules/kakoune/colors/haskell.nix @@ -0,0 +1,21 @@ +# Haskell text faces and other stuff related to syntax highlighting +# for Haskell in Kakoune, because I prefer different color arrangements +# per language. + +{ theme, pkgs, ... }: pkgs.writeTextFile (rec { + name = "haskell.kak"; + destination = "/share/kak/colors/${name}"; + text = with theme; '' + face global value rgb:${green.bright} + face global string rgb:${green.bright} + face global variable +b + face global module rgb:${green.normal} + face global meta rgb:${misc.lime} + face global operator rgb:${cyan.bright} + face global type rgb:${yellow.normal} + face global function rgb:${cyan.bright} + face global attribute rgb:${blue.normal} + face global keyword rgb:${blue.normal} + face global builtin +b + ''; +}) diff --git a/modules/kakoune/colors/nix.nix b/modules/kakoune/colors/nix.nix new file mode 100644 index 0000000..8e2bafd --- /dev/null +++ b/modules/kakoune/colors/nix.nix @@ -0,0 +1,19 @@ +# Haskell text faces and other stuff related to syntax highlighting +# for Haskell in Kakoune, because I prefer different color arrangements +# per language. + +{ theme, pkgs, ... }: pkgs.writeTextFile (rec { + name = "nix.kak"; + destination = "/share/kak/colors/${name}"; + text = with theme; '' + + add-highlighter buffer/ regex '\b\s*(=)' 1:operator + + face global string rgb:${green.normal} + face global operator rgb:${yellow.bright}+b + face global keyword rgb:${blue.normal}+b + face global meta rgb:${purple.bright} + face global builtin rgb:${blue.bright}+b + + ''; +}) diff --git a/modules/kakoune/colors/rust.nix b/modules/kakoune/colors/rust.nix new file mode 100644 index 0000000..ab6ebc4 --- /dev/null +++ b/modules/kakoune/colors/rust.nix @@ -0,0 +1,44 @@ +# Haskell text faces and other stuff related to syntax highlighting +# for Haskell in Kakoune, because I prefer different color arrangements +# per language. + +{ theme, pkgs, ... }: pkgs.writeTextFile (rec { + name = "rust.kak"; + destination = "/share/kak/colors/${name}"; + text = with theme; '' + + # Types + face global variant rgb:${green.bright}+b + face global enum rgb:${green.bright}+b + face global struct rgb:${red.pastel}+b + face global alias rgb:${orange.normal}+b + face global primitive rgb:${misc.teal}+b + face global trait rgb:${purple.bright}+b + face global union rgb:${misc.lime}+b + + # Other Rust-specific syntax elements + face global lifetime rgb:${cyan.bright} + face global format rgb:${orange.bright}+b + face global macro rgb:fc4cbf+b + + # Keywords + face global keyword rgb:${blue.normal} + + # Literals + face global literal rgb:${yellow.bright} + face global string rgb:${yellow.bright} + + # Items + face global function rgb:${green.normal} + face global method function + face global module rgb:${misc.blueGrey} + + # Other stuff + face global attribute comment + face global variable rgb:${foreground.normal} + face global property rgb:${misc.lime} + face global operator rgb:${yellow.normal} + face global punctuation rgb:${foreground.normal} + + ''; +}) diff --git a/modules/kakoune/default.nix b/modules/kakoune/default.nix new file mode 100644 index 0000000..ada0ee7 --- /dev/null +++ b/modules/kakoune/default.nix @@ -0,0 +1,213 @@ +{ lib, pkgs, config, ... }: + +let kakrc = pkgs.writeTextFile (rec { + name = "kakrc.kak"; + destination = "/share/kak/autoload/${name}"; + text = with (import ../../colors.nix)."dark"; '' + + # Line numbering + add-highlighter global/ number-lines -separator ' │ ' -hlcursor + + # Setting the tabstop to 4 (even though I have an ultrawide monitor) + set-option global tabstop 4 + + set global ui_options ncurses_assistant=cat + + # Use Alt-Tab to switch between open buffers + map global insert :buffer-next + map global normal :buffer-next + + colorscheme common + + face global LineNumbers rgb:${background.slight} + face global BufferPadding rgb:${background.slight} + face global LineNumberCursor rgb:${foreground.primary} + face global crosshairs_line "default,rgb:${background.normal}" + face global MenuForeground "default,blue" + face global MenuBackground "default,rgb:313131" + face global InlayHint rgb:828282 + + face global comment rgb:${foreground.slight} + + '' + (lib.optionalString (config.riley.ide) '' + + eval %sh{ kak-lsp --kakoune -s $kak_session } + + hook global -group yeet ModuleLoaded rust %{ + + # Override the Rust highlighting with semantic + # tokens supplied by the LSP client + remove-hooks global rust-highlight + remove-highlighter shared/rust + + # Request tokens + lsp-semantic-tokens + + # Self-destruct this hook (it should only run once) + remove-hooks global yeet + + } + + # Load language-specific color schemes + hook global WinSetOption filetype=(haskell) %{ + + colorscheme haskell + lsp-enable-window + + lsp-inlay-diagnostics-enable global + + map global ': lsp-code-actions' + map global ': lsp-hover' + + } + + hook global WinSetOption filetype=(rust) %{ + + lsp-enable-window + lsp-inlay-diagnostics-enable window + + colorscheme rust + + hook window -group semtok BufReload .* lsp-semantic-tokens + hook window -group semtok NormalIdle .* lsp-semantic-tokens + hook window -group semtok InsertIdle .* lsp-semantic-tokens + + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window semtok + } + + hook window ModeChange .*:.*:insert %{ + remove-highlighter window/lsp_diagnostics + } + + hook window ModeChange .*:insert:normal %{ + lsp-inlay-diagnostics-enable window + } + + set global lsp_inlay_diagnostic_sign '>' + + map global normal ': lsp-code-actions' + map global normal ': lsp-hover' + + } + + hook global WinSetOption filetype=(nix) %{ + colorscheme nix + lsp-enable-window + } + + face global InlayDiagnosticWarning rgb:a39e31+f + face global InlayDiagnosticError rgb:ad494f+f + face global InlayDiagnosticHint rgb:4d965a+f + + ''); + }); + + # Syntax colors + colors = (import ./colors { + theme = (import ../../colors.nix)."dark"; + inherit lib pkgs; + }); + + # Config for kak-lsp + kak-lsp-config = pkgs.writeTextFile (rec { + name = "kak-lsp.toml"; + destination = "/share/kak-lsp/${name}"; + text = let semTok = (name: value: '' + [[semantic_tokens]] + token = "${name}" + face = "${value}" + ''); in '' + + [language.rust] + filetypes = [ "rust" ] + roots = [ "Cargo.toml" ] + command = "rust-analyzer" + [language.rust.settings.rust-analyzer] + semanticTokens = true + diagnostics.enabled = [ "unresolved-proc-macro" ] + cargo.loadOutDirsFromCheck = true + procMacro.enable = false + + [language.haskell] + filetypes = [ "haskell" ] + roots = [ "Setup.hs", "stack.yaml", "*.cabal" ] + command = "haskell-language-server-wrapper" + args = [ "--lsp" ] + + [language.nix] + filetypes = [ "nix" ] + roots = [ "flake.nix", "shell.nix", ".git", ".hg" ] + command = "rnix-lsp" + + ${lib.concatStringsSep "\n" (lib.mapAttrsToList semTok { + "enumMember" = "variant"; + "enum" = "enum"; + "union" = "union"; + "struct" = "struct"; + "typeAlias" = "alias"; + "builtinType" = "primitive"; + "trait" = "trait"; + "interface" = "trait"; + "method" = "method"; + "function" = "function"; + "namespace" = "module"; + "boolean" = "literal"; + "character" = "literal"; + "number" = "literal"; + "string" = "string"; + "keyword" = "keyword"; + "documentation" = "comment"; + "comment" = "comment"; + "escapeSequence" = "format"; + "formatSpecifier" = "format"; + "operator" = "operator"; + "arithmetic" = "operator"; + "bitwise" = "operator"; + "comparison" = "operator"; + "logical" = "operator"; + "macro" = "macro"; + "lifetime" = "lifetime"; + "variable" = "variable"; + "attribute" = "attribute"; + "punctuation" = "punctuation"; + }) } + ''; + }); + +in { + environment.systemPackages = with pkgs; [ + + (pkgs.kakoune.override { + plugins = with kakounePlugins; [ + + # Custom config + kakrc + + # Kakoune language server support + (symlinkJoin { + paths = [ + + # The language server client + kak-lsp + + # Include default language servers + rnix-lsp + haskell-language-server + + # Overwrite kak-lsp.toml + kak-lsp-config + + ]; + name = "kak-lsp-${kak-lsp.version}"; + nativeBuildInputs = [ makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml" + ''; + }) + + ] ++ colors; + }) + + ]; +}