This commit is contained in:
Daniel Flanagan 2024-06-25 09:38:00 -05:00
parent 7efd72ded7
commit f87fbad500
4 changed files with 38 additions and 72 deletions

View file

@ -32,17 +32,10 @@
... ...
} @ inputs: let } @ inputs: let
# TODO: make @ inputs unnecessary by making arguments explicit in all modules? # 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"];
forSystems = nixpkgs.lib.genAttrs systems;
systems = [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: import nixpkgs {inherit system;}; pkgsFor = system: import nixpkgs {inherit system;};
genPkgs = f: (f (forSystems pkgsFor));
in { in {
colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire; colors = (import ./lib/colors.nix {inherit (nixpkgs) lib;}).schemes.catppuccin-mocha-sapphire;
# colors = (import ./lib/colors.nix inputs).color-schemes.donokai; # colors = (import ./lib/colors.nix inputs).color-schemes.donokai;
@ -52,19 +45,10 @@
size = 12; size = 12;
}; };
# Your custom packages packages = genPkgs (pkgs: import ./packages {inherit pkgs;});
# Acessible through 'nix build', 'nix shell', etc formatter = genPkgs (pkgs: pkgs.alejandra);
packages = forAllSystems (system: checks = genPkgs (pkgs: {
import ./packages { pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
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 {
src = ./.; src = ./.;
hooks = { hooks = {
alejandra.enable = true; alejandra.enable = true;
@ -72,30 +56,19 @@
}; };
}); });
devShell = forAllSystems (system: let devShell = genPkgs (pkgs:
pkgs = pkgsFor system;
in
pkgs.mkShell { pkgs.mkShell {
inherit (outputs.checks.${system}.pre-commit-check) shellHook; inherit (self.outputs.checks.${pkgs.system}.pre-commit-check) shellHook;
buildInputs = with pkgs; [ buildInputs = with pkgs; [
lua-language-server lua-language-server
]; ];
}); });
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays {inherit nixpkgs;}; 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; 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; homeManagerModules = import ./modules/home-manager;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations = nixosConfigurations =
(builtins.mapAttrs (name: { (builtins.mapAttrs (name: {
system, system,
@ -109,7 +82,8 @@
inherit system; inherit system;
specialArgs = { specialArgs = {
# TODO: avoid special args and actually pass inputs to modules? # TODO: avoid special args and actually pass inputs to modules?
inherit inputs outputs hardware; inherit (self) outputs;
inherit inputs hardware;
}; };
# extraSpecialArgs = { # extraSpecialArgs = {
# inherit inputs outputs system; # inherit inputs outputs system;
@ -121,11 +95,11 @@
++ modules; ++ modules;
}) (import ./nixos)) }) (import ./nixos))
// { // {
# TODO: stabilize "appliance"-type hosts on stable nixpkgs ASAP to avoid breakages
beefcake = nixpkgs.lib.nixosSystem { beefcake = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = { specialArgs = {
inherit inputs outputs hardware; inherit (self) outputs;
inherit inputs hardware;
}; };
modules = [self.nixosModules.common ./nixos/beefcake.nix]; 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 = { homeConfigurations = {
# TODO: non-system-specific home configurations? # TODO: non-system-specific home configurations?
"deck" = let "deck" = let
@ -149,10 +121,11 @@
home-manager.lib.homeManagerConfiguration { home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor system; pkgs = pkgsFor system;
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs outputs system; inherit (self) outputs;
inherit (outputs) colors font; inherit inputs system;
inherit (self.outputs) colors font;
}; };
modules = with outputs.homeManagerModules; [ modules = with self.outputs.homeManagerModules; [
common common
{ {
home.homeDirectory = "/home/deck"; home.homeDirectory = "/home/deck";
@ -168,10 +141,11 @@
home-manager.lib.homeManagerConfiguration { home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor system; pkgs = pkgsFor system;
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs outputs system; inherit (self) outputs;
inherit (outputs) colors font; inherit inputs system;
inherit (self.outputs) colors font;
}; };
modules = with outputs.homeManagerModules; [ modules = with self.outputs.homeManagerModules; [
common common
{ {
home.homeDirectory = "/Users/daniel.flanagan"; home.homeDirectory = "/Users/daniel.flanagan";
@ -183,10 +157,7 @@
}; };
}; };
# Disk partition schemes and functions
diskoConfigurations = import ./disko; diskoConfigurations = import ./disko;
# Flake templates for easily setting up Nix in a project using common patterns I like
templates = import ./templates/all.nix; templates = import ./templates/all.nix;
# TODO: nix-on-droid for phone terminal usage? # TODO: nix-on-droid for phone terminal usage?

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
N journal

View file

@ -31,9 +31,10 @@
google-chrome google-chrome
]; ];
services.udev.packages = [ services.udev.packages = with pkgs; [
pkgs.platformio platformio
pkgs.openocd openocd
via
]; ];
programs.adb.enable = true; programs.adb.enable = true;

View file

@ -8,22 +8,15 @@
pre-commit-hooks, pre-commit-hooks,
... ...
}: let }: let
inherit (self) outputs; systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"];
forSystems = nixpkgs.lib.genAttrs systems;
supportedSystems = [ pkgsFor = system: import nixpkgs {inherit system;};
"aarch64-linux" genPkgs = f: (f (forSystems pkgsFor));
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in { in {
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); formatter = genPkgs (pkgs: pkgs.alejandra);
checks = forAllSystems (system: { checks = genPkgs (pkgs: {
pre-commit-check = pre-commit-hooks.lib.${system}.run { pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
src = ./.; src = ./.;
hooks = { hooks = {
alejandra.enable = true; alejandra.enable = true;
@ -31,15 +24,13 @@
}; };
}); });
devShell = forAllSystems (system: let devShell = genPkgs (pkgs:
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShell { pkgs.mkShell {
buildInputs = with pkgs; [nil alejandra]; 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; # overlays = import ./overlays self;
# nixosModules = import ./modules/nixos; # nixosModules = import ./modules/nixos;
# homeManagerModules = import ./modules/home-manager; # homeManagerModules = import ./modules/home-manager;