diff --git a/flake.nix b/flake.nix index eb22755..360b53e 100644 --- a/flake.nix +++ b/flake.nix @@ -31,102 +31,122 @@ flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/0.1.tar.gz"; }; - outputs = { self, nixpkgs, nixos-wsl, nix-darwin, neovim-overlay, rust-overlay, flake-schemas }: + outputs = + { + self, + nixpkgs, + nixos-wsl, + nix-darwin, + neovim-overlay, + rust-overlay, + flake-schemas, + }: let allSystems = [ "x86_64-linux" "aarch64-darwin" ]; - forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { - pkgs = nixpkgs.legacyPackages.${system}; - pkgs-rust = rust-overlay.packages.${system}; - }); + forAllSystems = + f: + nixpkgs.lib.genAttrs allSystems ( + system: + f { + pkgs = nixpkgs.legacyPackages.${system}; + pkgs-rust = rust-overlay.packages.${system}; + } + ); mkNix = pkgs: { package = pkgs.nixVersions.latest; - settings.experimental-features = [ "nix-command" "flakes" ]; - }; - - mkSystemPackages = pkgs: with pkgs; [ - pkgsBuildBuild.wezterm.terminfo - ]; - - mkUser = pkgs: with pkgs; { - shell = zsh; - packages = [ - git - gnumake - curl - jq - yq-go - fzf - bat - ripgrep - neovim-overlay.packages.${system}.default + settings.experimental-features = [ + "nix-command" + "flakes" ]; }; - in - { - inherit (flake-schemas) schemas; - formatter = forAllSystems ({ pkgs, ... }: pkgs.nixpkgs-fmt); + mkSystemPackages = pkgs: with pkgs; [ pkgsBuildBuild.wezterm.terminfo ]; - devShells = forAllSystems ({ pkgs, pkgs-rust }: { - go = with pkgs; mkShell { - name = "go"; + mkUser = + pkgs: with pkgs; { + shell = zsh; packages = [ - go - gopls - golangci-lint - gofumpt - delve - gomodifytags - gotests - impl + git + gnumake + curl + jq + yq-go + fzf + bat + ripgrep + neovim-overlay.packages.${system}.default ]; }; + in + { + inherit (flake-schemas) schemas; - rust = pkgs.mkShell { - name = "rust"; - packages = [ - pkgs-rust.default - ]; - }; - }); + formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); + + devShells = forAllSystems ( + { pkgs, pkgs-rust }: + { + go = + with pkgs; + mkShell { + name = "go"; + packages = [ + go + gopls + golangci-lint + gofumpt + delve + gomodifytags + gotests + impl + ]; + }; + + rust = pkgs.mkShell { + name = "rust"; + packages = [ pkgs-rust.default ]; + }; + } + ); nixosConfigurations = { calavera = nixpkgs.lib.nixosSystem { modules = [ nixos-wsl.nixosModules.default - ({ pkgs, ... }: { - nixpkgs.hostPlatform = "x86_64-linux"; + ( + { pkgs, ... }: + { + nixpkgs.hostPlatform = "x86_64-linux"; - networking.hostName = "calavera"; + networking.hostName = "calavera"; - wsl = { - enable = true; - defaultUser = "acotten"; - }; + wsl = { + enable = true; + defaultUser = "acotten"; + }; - users.users.acotten = mkUser pkgs; + users.users.acotten = mkUser pkgs; - # 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 = "24.05"; + # 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 = "24.05"; - nix = mkNix pkgs; + nix = mkNix pkgs; - environment.systemPackages = mkSystemPackages pkgs ++ (with pkgs; [ - keychain - ]); + environment.systemPackages = mkSystemPackages pkgs ++ (with pkgs; [ keychain ]); - programs.zsh.enable = true; - }) + programs.zsh.enable = true; + } + ) ]; }; }; @@ -134,93 +154,110 @@ darwinConfigurations = { colomar = nix-darwin.lib.darwinSystem { modules = [ - ({ pkgs, ... }: { - nixpkgs.hostPlatform = "aarch64-darwin"; + ( + { pkgs, ... }: + { + nixpkgs.hostPlatform = "aarch64-darwin"; - networking.hostName = "colomar"; + networking.hostName = "colomar"; - users = { - knownUsers = [ "acotten" ]; - users.acotten = mkUser pkgs // { uid = 501; }; - }; + users = { + knownUsers = [ "acotten" ]; + users.acotten = mkUser pkgs // { + uid = 501; + }; + }; - # Used for backwards compatibility, similarly to NixOS. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://daiderd.com/nix-darwin/manual/). - system.stateVersion = 4; + # Used for backwards compatibility, similarly to NixOS. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://daiderd.com/nix-darwin/manual/). + system.stateVersion = 4; - services.nix-daemon.enable = true; + services.nix-daemon.enable = true; - nix = mkNix pkgs; + nix = mkNix pkgs; - environment = { - shells = [ pkgs.zsh ]; - systemPackages = mkSystemPackages pkgs; - }; + environment = { + shells = [ pkgs.zsh ]; + systemPackages = mkSystemPackages pkgs; + }; - programs.zsh.enable = true; + programs.zsh.enable = true; - system.defaults = { - NSGlobalDomain = { - InitialKeyRepeat = 15; - KeyRepeat = 2; - }; - CustomUserPreferences = { + system.defaults = { NSGlobalDomain = { - AppleLanguages = [ "en-US" "de-DE" "fr-FR" ]; - AppleLocale = "en_US@rg=dezzzz"; - NSLinguisticDataAssetsRequested = [ "en" "de" "fr" ]; - }; - "com.apple.HIToolbox" = { - AppleEnabledInputSources = [ - { - InputSourceKind = "Keyboard Layout"; - "KeyboardLayout Name" = "ABC"; - "KeyboardLayout ID" = 252; - } - { - InputSourceKind = "Non Keyboard Input Method"; - "Bundle ID" = "com.apple.CharacterPaletteIM"; - } - { - InputSourceKind = "Non Keyboard Input Method"; - "Bundle ID" = "com.apple.PressAndHold"; - } - { - InputSourceKind = "Keyboard Layout"; - "KeyboardLayout Name" = "US Extended"; - "KeyboardLayout ID" = -2; - } - { - InputSourceKind = "Keyboard Layout"; - "KeyboardLayout Name" = "USInternational-PC"; - "KeyboardLayout ID" = 15000; - } - ]; + InitialKeyRepeat = 15; + KeyRepeat = 2; }; - "com.apple.symbolichotkeys" = { - AppleSymbolicHotKeys = { - # Input Sources > Select the previous input source - "60" = { - # Control-Option-Space - # Originally Control-Space, which conflicts with my Neovim completion keymap. - value = { - parameters = [ 32 49 786432 ]; - type = "standard"; + CustomUserPreferences = { + NSGlobalDomain = { + AppleLanguages = [ + "en-US" + "de-DE" + "fr-FR" + ]; + AppleLocale = "en_US@rg=dezzzz"; + NSLinguisticDataAssetsRequested = [ + "en" + "de" + "fr" + ]; + }; + "com.apple.HIToolbox" = { + AppleEnabledInputSources = [ + { + InputSourceKind = "Keyboard Layout"; + "KeyboardLayout Name" = "ABC"; + "KeyboardLayout ID" = 252; + } + { + InputSourceKind = "Non Keyboard Input Method"; + "Bundle ID" = "com.apple.CharacterPaletteIM"; + } + { + InputSourceKind = "Non Keyboard Input Method"; + "Bundle ID" = "com.apple.PressAndHold"; + } + { + InputSourceKind = "Keyboard Layout"; + "KeyboardLayout Name" = "US Extended"; + "KeyboardLayout ID" = -2; + } + { + InputSourceKind = "Keyboard Layout"; + "KeyboardLayout Name" = "USInternational-PC"; + "KeyboardLayout ID" = 15000; + } + ]; + }; + "com.apple.symbolichotkeys" = { + AppleSymbolicHotKeys = { + # Input Sources > Select the previous input source + "60" = { + # Control-Option-Space + # Originally Control-Space, which conflicts with my Neovim completion keymap. + value = { + parameters = [ + 32 + 49 + 786432 + ]; + type = "standard"; + }; + enabled = true; + }; + # Input Sources > Select the next source in Input menu + "61" = { + # Disabled to free the Control-Option-Space hotkey for + # "Select the previous input source" above. + enabled = false; }; - enabled = true; - }; - # Input Sources > Select the next source in Input menu - "61" = { - # Disabled to free the Control-Option-Space hotkey for - # "Select the previous input source" above. - enabled = false; }; }; }; }; - }; - }) + } + ) ]; }; };