Skip to content

Commit

Permalink
nix: Switch formatter from nixpkgs-fmt to nixfmt
Browse files Browse the repository at this point in the history
nixpkgs-fmt was archived[1] in favour of nixfmt[2], which implements the
Nix RFC 166[3].

See NixOS/nixfmt#153 for further details about the progress of the
implementation.

[1]: https://x.com/zimbatm/status/1816148339131343058
[2]: https://github.com/NixOS/nixfmt?tab=readme-ov-file#readme
[3]: https://github.com/nix-rfc-101/rfcs/blob/aaf1613f/rfcs/0166-nix-formatting.md
  • Loading branch information
antoineco committed Sep 5, 2024
1 parent 83ec9dd commit 07b80fb
Showing 1 changed file with 176 additions and 139 deletions.
315 changes: 176 additions & 139 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,196 +31,233 @@
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;
}
)
];
};
};

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;
};
};
};
};
};
})
}
)
];
};
};
Expand Down

0 comments on commit 07b80fb

Please sign in to comment.