From 63975152b0a46aabdefadad24917d1caf67b3747 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Sat, 16 Sep 2023 18:41:44 -0300 Subject: [PATCH] add alejandra as formatter Co-authored-by: uf5 --- flake.lock | 27 +++++ flake.nix | 16 ++- minimal/flake.nix | 15 ++- minimal/home-manager/home.nix | 11 +- minimal/nixos/configuration.nix | 13 ++- standard/flake.nix | 117 ++++++++++++---------- standard/home-manager/home.nix | 12 ++- standard/modules/home-manager/default.nix | 1 - standard/modules/nixos/default.nix | 1 - standard/nixos/configuration.nix | 14 ++- standard/nixpkgs.nix | 11 +- standard/overlays/default.nix | 5 +- standard/pkgs/default.nix | 3 +- standard/shell.nix | 5 +- 14 files changed, 161 insertions(+), 90 deletions(-) create mode 100644 flake.lock diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0d09824 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1694753796, + "narHash": "sha256-QPE7dqcicQH/nq9aywVXJWWtci4FvxHaM+BSIEbGBvA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "360a7d31c30abefdc490d203f80e3221b7a24af2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 591094b..30648da 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,19 @@ { description = "NixOS + standalone home-manager config flakes to get you started!"; - outputs = inputs: { + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + }; + + outputs = {nixpkgs, ...}: let + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + in { templates = { minimal = { description = '' @@ -17,5 +30,6 @@ path = ./standard; }; }; + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); }; } diff --git a/minimal/flake.nix b/minimal/flake.nix index 97e3ebc..0a7f96d 100644 --- a/minimal/flake.nix +++ b/minimal/flake.nix @@ -17,7 +17,12 @@ # nix-colors.url = "github:misterio77/nix-colors"; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: let + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let inherit (self) outputs; in { # NixOS configuration entrypoint @@ -25,9 +30,9 @@ nixosConfigurations = { # FIXME replace with your hostname your-hostname = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = {inherit inputs outputs;}; # > Our main nixos configuration file < - modules = [ ./nixos/configuration.nix ]; + modules = [./nixos/configuration.nix]; }; }; @@ -37,9 +42,9 @@ # FIXME replace with your username@hostname "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs outputs; }; + extraSpecialArgs = {inherit inputs outputs;}; # > Our main home-manager configuration file < - modules = [ ./home-manager/home.nix ]; + modules = [./home-manager/home.nix]; }; }; }; diff --git a/minimal/home-manager/home.nix b/minimal/home-manager/home.nix index 2e70f6b..5f20559 100644 --- a/minimal/home-manager/home.nix +++ b/minimal/home-manager/home.nix @@ -1,7 +1,12 @@ # This is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) - -{ inputs, lib, config, pkgs, ... }: { +{ + inputs, + lib, + config, + pkgs, + ... +}: { # You can import other home-manager modules here imports = [ # If you want to use home-manager modules from other flakes (such as nix-colors): @@ -29,7 +34,7 @@ # Disable if you don't want unfree packages allowUnfree = true; # Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = (_: true); + allowUnfreePredicate = _: true; }; }; diff --git a/minimal/nixos/configuration.nix b/minimal/nixos/configuration.nix index bb29905..11c0c3a 100644 --- a/minimal/nixos/configuration.nix +++ b/minimal/nixos/configuration.nix @@ -1,7 +1,12 @@ # This is your system's configuration file. # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) - -{ inputs, lib, config, pkgs, ... }: { +{ + inputs, + lib, + config, + pkgs, + ... +}: { # You can import other NixOS modules here imports = [ # If you want to use modules from other flakes (such as nixos-hardware): @@ -38,7 +43,7 @@ nix = { # This will add each flake input as a registry # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + registry = lib.mapAttrs (_: value: {flake = value;}) inputs; # This will additionally add your inputs to the system's legacy channels # Making legacy nix commands consistent as well, awesome! @@ -73,7 +78,7 @@ # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect ]; # TODO: Be sure to add any other groups you need (such as networkmanager, audio, docker, etc) - extraGroups = [ "wheel" ]; + extraGroups = ["wheel"]; }; }; diff --git a/standard/flake.nix b/standard/flake.nix index 52b6564..96650e8 100644 --- a/standard/flake.nix +++ b/standard/flake.nix @@ -21,64 +21,71 @@ # nix-colors.url = "github:misterio77/nix-colors"; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: - let - inherit (self) outputs; - forAllSystems = nixpkgs.lib.genAttrs [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - in { - # Your custom packages - # Acessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./pkgs { inherit pkgs; } - ); - # Devshell for bootstrapping - # Acessible through 'nix develop' or 'nix-shell' (legacy) - devShells = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./shell.nix { inherit pkgs; } - ); + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + pkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); + in { + # Your custom packages + # Acessible through 'nix build', 'nix shell', etc + packages = forAllSystems ( + system: import ./pkgs {pkgs = pkgsFor.${system};} + ); + # Devshell for bootstrapping + # Acessible through 'nix develop' or 'nix-shell' (legacy) + devShells = forAllSystems ( + system: import ./shell.nix {pkgs = pkgsFor.${system};} + ); - # Your custom packages and modifications, exported as overlays - overlays = import ./overlays { inherit inputs; }; - # Reusable nixos modules you might want to export - # These are usually stuff you would upstream into nixpkgs - nixosModules = import ./modules/nixos; - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager - homeManagerModules = import ./modules/home-manager; + # Formatter for your nix files, available through 'nix fmt' + # Other options beside 'alejandra' include 'nixpkgs-fmt' + formatter = forAllSystems (system: pkgsFor.${system}.alejandra); - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' - nixosConfigurations = { - # FIXME replace with your hostname - your-hostname = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nixos/configuration.nix - ]; - }; - }; + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays {inherit inputs;}; + # Reusable nixos modules you might want to export + # These are usually stuff you would upstream into nixpkgs + nixosModules = import ./modules/nixos; + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home-manager; - # Standalone home-manager configuration entrypoint - # Available through 'home-manager --flake .#your-username@your-hostname' - homeConfigurations = { - # FIXME replace with your username@hostname - "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main home-manager configuration file < - ./home-manager/home.nix - ]; - }; + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + # FIXME replace with your hostname + your-hostname = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + modules = [ + # > Our main nixos configuration file < + ./nixos/configuration.nix + ]; }; }; + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + homeConfigurations = { + # FIXME replace with your username@hostname + "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance + extraSpecialArgs = {inherit inputs outputs;}; + modules = [ + # > Our main home-manager configuration file < + ./home-manager/home.nix + ]; + }; + }; + }; } diff --git a/standard/home-manager/home.nix b/standard/home-manager/home.nix index 4198f3b..eedacc2 100644 --- a/standard/home-manager/home.nix +++ b/standard/home-manager/home.nix @@ -1,7 +1,13 @@ # This is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) - -{ inputs, outputs, lib, config, pkgs, ... }: { +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { # You can import other home-manager modules here imports = [ # If you want to use modules your own flake exports (from modules/home-manager): @@ -37,7 +43,7 @@ # Disable if you don't want unfree packages allowUnfree = true; # Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = (_: true); + allowUnfreePredicate = _: true; }; }; diff --git a/standard/modules/home-manager/default.nix b/standard/modules/home-manager/default.nix index e41f7d9..45aae31 100644 --- a/standard/modules/home-manager/default.nix +++ b/standard/modules/home-manager/default.nix @@ -1,6 +1,5 @@ # Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module). # These should be stuff you would like to share with others, not your personal configurations. - { # List your module files here # my-module = import ./my-module.nix; diff --git a/standard/modules/nixos/default.nix b/standard/modules/nixos/default.nix index bec6184..8605069 100644 --- a/standard/modules/nixos/default.nix +++ b/standard/modules/nixos/default.nix @@ -1,6 +1,5 @@ # Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module). # These should be stuff you would like to share with others, not your personal configurations. - { # List your module files here # my-module = import ./my-module.nix; diff --git a/standard/nixos/configuration.nix b/standard/nixos/configuration.nix index e187383..a72f947 100644 --- a/standard/nixos/configuration.nix +++ b/standard/nixos/configuration.nix @@ -1,7 +1,13 @@ # This is your system's configuration file. # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) - -{ inputs, outputs, lib, config, pkgs, ... }: { +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { # You can import other NixOS modules here imports = [ # If you want to use modules your own flake exports (from modules/nixos): @@ -46,7 +52,7 @@ nix = { # This will add each flake input as a registry # To make nix3 commands consistent with your flake - registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + registry = lib.mapAttrs (_: value: {flake = value;}) inputs; # This will additionally add your inputs to the system's legacy channels # Making legacy nix commands consistent as well, awesome! @@ -81,7 +87,7 @@ # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect ]; # TODO: Be sure to add any other groups you need (such as networkmanager, audio, docker, etc) - extraGroups = [ "wheel" ]; + extraGroups = ["wheel"]; }; }; diff --git a/standard/nixpkgs.nix b/standard/nixpkgs.nix index 041de40..e4d0588 100644 --- a/standard/nixpkgs.nix +++ b/standard/nixpkgs.nix @@ -1,8 +1,9 @@ # A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file # This is useful to avoid using channels when using legacy nix commands -let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; +let + lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; in -import (fetchTarball { - url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; - sha256 = lock.narHash; -}) + import (fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; + sha256 = lock.narHash; + }) diff --git a/standard/overlays/default.nix b/standard/overlays/default.nix index 9a03471..a13ea3c 100644 --- a/standard/overlays/default.nix +++ b/standard/overlays/default.nix @@ -1,8 +1,7 @@ # This file defines overlays -{ inputs, ... }: -{ +{inputs, ...}: { # This one brings our custom packages from the 'pkgs' directory - additions = final: _prev: import ../pkgs { pkgs = final; }; + additions = final: _prev: import ../pkgs {pkgs = final;}; # This one contains whatever you want to overlay # You can change versions, add patches, set compilation flags, anything really. diff --git a/standard/pkgs/default.nix b/standard/pkgs/default.nix index 8c5e910..7403a05 100644 --- a/standard/pkgs/default.nix +++ b/standard/pkgs/default.nix @@ -1,6 +1,5 @@ # Custom packages, that can be defined similarly to ones from nixpkgs # You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' - -{ pkgs ? (import ../nixpkgs.nix) { } }: { +{pkgs ? (import ../nixpkgs.nix) {}}: { # example = pkgs.callPackage ./example { }; } diff --git a/standard/shell.nix b/standard/shell.nix index 9525915..5982048 100644 --- a/standard/shell.nix +++ b/standard/shell.nix @@ -1,10 +1,9 @@ # Shell for bootstrapping flake-enabled nix and home-manager # You can enter it through 'nix develop' or (legacy) 'nix-shell' - -{ pkgs ? (import ./nixpkgs.nix) { } }: { +{pkgs ? (import ./nixpkgs.nix) {}}: { default = pkgs.mkShell { # Enable experimental features without having to specify the argument NIX_CONFIG = "experimental-features = nix-command flakes"; - nativeBuildInputs = with pkgs; [ nix home-manager git ]; + nativeBuildInputs = with pkgs; [nix home-manager git]; }; }