From f87fbad500e0537d47788a2f4d9e23c077a1178e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 25 Jun 2024 09:38:00 -0500 Subject: [PATCH] Cleanup --- flake.nix | 71 +++++++---------------- modules/home-manager/scripts/common/bin/j | 3 + modules/nixos/development-tools.nix | 7 ++- templates/nix-flake/flake.nix | 29 ++++----- 4 files changed, 38 insertions(+), 72 deletions(-) create mode 100755 modules/home-manager/scripts/common/bin/j diff --git a/flake.nix b/flake.nix index 33bd03e..43f8b78 100644 --- a/flake.nix +++ b/flake.nix @@ -32,17 +32,10 @@ ... } @ inputs: let # TODO: make @ inputs unnecessary by making arguments explicit in all modules? - inherit (self) outputs; - - systems = [ - "aarch64-linux" - "aarch64-darwin" - "x86_64-darwin" - "x86_64-linux" - ]; - - forAllSystems = nixpkgs.lib.genAttrs systems; + systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; + forSystems = nixpkgs.lib.genAttrs systems; pkgsFor = system: import nixpkgs {inherit system;}; + genPkgs = f: (f (forSystems pkgsFor)); in { colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire; # colors = (import ./lib/colors.nix inputs).color-schemes.donokai; @@ -52,19 +45,10 @@ size = 12; }; - # Your custom packages - # Acessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: - import ./packages { - pkgs = pkgsFor system; - }); - - # Formatter for your nix files, available through 'nix fmt' - # Other options beside 'alejandra' include 'nixpkgs-fmt' - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); - - checks = forAllSystems (system: { - pre-commit-check = pre-commit-hooks.lib.${system}.run { + packages = genPkgs (pkgs: import ./packages {inherit pkgs;}); + formatter = genPkgs (pkgs: pkgs.alejandra); + checks = genPkgs (pkgs: { + pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run { src = ./.; hooks = { alejandra.enable = true; @@ -72,30 +56,19 @@ }; }); - devShell = forAllSystems (system: let - pkgs = pkgsFor system; - in + devShell = genPkgs (pkgs: pkgs.mkShell { - inherit (outputs.checks.${system}.pre-commit-check) shellHook; + inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook; buildInputs = with pkgs; [ lua-language-server ]; }); - # Your custom packages and modifications, exported as overlays overlays = import ./overlays {inherit nixpkgs;}; - - # 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; - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = (builtins.mapAttrs (name: { system, @@ -109,7 +82,8 @@ inherit system; specialArgs = { # TODO: avoid special args and actually pass inputs to modules? - inherit inputs outputs hardware; + inherit (self) outputs; + inherit inputs hardware; }; # extraSpecialArgs = { # inherit inputs outputs system; @@ -121,11 +95,11 @@ ++ modules; }) (import ./nixos)) // { - # TODO: stabilize "appliance"-type hosts on stable nixpkgs ASAP to avoid breakages beefcake = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { - inherit inputs outputs hardware; + inherit (self) outputs; + inherit inputs hardware; }; modules = [self.nixosModules.common ./nixos/beefcake.nix]; }; @@ -139,8 +113,6 @@ # }; }; - # Standalone home-manager configuration entrypoint - # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { # TODO: non-system-specific home configurations? "deck" = let @@ -149,10 +121,11 @@ home-manager.lib.homeManagerConfiguration { pkgs = pkgsFor system; extraSpecialArgs = { - inherit inputs outputs system; - inherit (outputs) colors font; + inherit (self) outputs; + inherit inputs system; + inherit (self.outputs) colors font; }; - modules = with outputs.homeManagerModules; [ + modules = with self.outputs.homeManagerModules; [ common { home.homeDirectory = "/home/deck"; @@ -168,10 +141,11 @@ home-manager.lib.homeManagerConfiguration { pkgs = pkgsFor system; extraSpecialArgs = { - inherit inputs outputs system; - inherit (outputs) colors font; + inherit (self) outputs; + inherit inputs system; + inherit (self.outputs) colors font; }; - modules = with outputs.homeManagerModules; [ + modules = with self.outputs.homeManagerModules; [ common { home.homeDirectory = "/Users/daniel.flanagan"; @@ -183,10 +157,7 @@ }; }; - # Disk partition schemes and functions diskoConfigurations = import ./disko; - - # Flake templates for easily setting up Nix in a project using common patterns I like templates = import ./templates/all.nix; # TODO: nix-on-droid for phone terminal usage? diff --git a/modules/home-manager/scripts/common/bin/j b/modules/home-manager/scripts/common/bin/j new file mode 100755 index 0000000..24fab3b --- /dev/null +++ b/modules/home-manager/scripts/common/bin/j @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +N journal diff --git a/modules/nixos/development-tools.nix b/modules/nixos/development-tools.nix index a2c4706..e022fdc 100644 --- a/modules/nixos/development-tools.nix +++ b/modules/nixos/development-tools.nix @@ -31,9 +31,10 @@ google-chrome ]; - services.udev.packages = [ - pkgs.platformio - pkgs.openocd + services.udev.packages = with pkgs; [ + platformio + openocd + via ]; programs.adb.enable = true; diff --git a/templates/nix-flake/flake.nix b/templates/nix-flake/flake.nix index 0bee6a4..0a7c099 100644 --- a/templates/nix-flake/flake.nix +++ b/templates/nix-flake/flake.nix @@ -8,22 +8,15 @@ pre-commit-hooks, ... }: let - inherit (self) outputs; - - supportedSystems = [ - "aarch64-linux" - "x86_64-linux" - - "aarch64-darwin" - "x86_64-darwin" - ]; - - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; + forSystems = nixpkgs.lib.genAttrs systems; + pkgsFor = system: import nixpkgs {inherit system;}; + genPkgs = f: (f (forSystems pkgsFor)); in { - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + formatter = genPkgs (pkgs: pkgs.alejandra); - checks = forAllSystems (system: { - pre-commit-check = pre-commit-hooks.lib.${system}.run { + checks = genPkgs (pkgs: { + pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run { src = ./.; hooks = { alejandra.enable = true; @@ -31,15 +24,13 @@ }; }); - devShell = forAllSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; - in + devShell = genPkgs (pkgs: pkgs.mkShell { buildInputs = with pkgs; [nil alejandra]; - inherit (outputs.checks.${system}.pre-commit-check) shellHook; + inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook; }); - # packages = forAllSystems (system: import ./pkgs {pkgs = nixpkgs.legacyPackages.${system};}); + # packages = genPkgs (pkgs: import ./pkgs {inherit pkgs;}); # overlays = import ./overlays self; # nixosModules = import ./modules/nixos; # homeManagerModules = import ./modules/home-manager;