mirror of
https://github.com/nmasur/dotfiles
synced 2025-03-14 16:57:06 +00:00
still working on consolidating
This commit is contained in:
parent
1eae89b8ab
commit
bf273925ad
@ -1,20 +0,0 @@
|
||||
# Return an atrset of all colorschemes
|
||||
|
||||
nixpkgs:
|
||||
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
in
|
||||
|
||||
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
|
||||
# Get only files ending in default.nix
|
||||
(builtins.filter (name: lib.hasSuffix "default.nix" name))
|
||||
# Import each colorscheme function
|
||||
(map (file: {
|
||||
name = builtins.baseNameOf (builtins.dirOf file);
|
||||
value = import file;
|
||||
}))
|
||||
# Convert to an attrset of colorscheme -> colors
|
||||
(builtins.listToAttrs)
|
||||
|
||||
]
|
187
flake.nix
187
flake.nix
@ -211,6 +211,7 @@
|
||||
{ nixpkgs, ... }@inputs:
|
||||
|
||||
let
|
||||
lib = import ./lib inputs;
|
||||
|
||||
# Global configuration for my systems
|
||||
globals =
|
||||
@ -250,136 +251,53 @@
|
||||
};
|
||||
};
|
||||
|
||||
colorscheme = import ./colorscheme;
|
||||
|
||||
# Common overlays to always use
|
||||
overlays = [
|
||||
inputs.nur.overlays.default
|
||||
inputs.nix2vim.overlay
|
||||
] ++ (import ./overlays inputs);
|
||||
|
||||
# System types to support.
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
|
||||
# { system -> pkgs }
|
||||
pkgsBySystem = forAllSystems (
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system overlays;
|
||||
config.permittedInsecurePackages = [ "litestream-0.3.13" ];
|
||||
config.allowUnfree = true;
|
||||
}
|
||||
);
|
||||
# stablePkgsBySystem = forAllSystems (system: import nixpkgs { inherit system overlays; });
|
||||
|
||||
buildHome =
|
||||
{ pkgs, modules }:
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
./platforms/home-manager
|
||||
];
|
||||
};
|
||||
|
||||
buildNixos =
|
||||
{ pkgs, modules }:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.wsl.nixosModules.wsl
|
||||
./platforms/nixos
|
||||
{
|
||||
home-manager.extraSpecialArgs = {
|
||||
hostnames = globals.hostnames;
|
||||
inherit colorscheme;
|
||||
};
|
||||
}
|
||||
];
|
||||
specialArgs = {
|
||||
hostnames = globals.hostnames;
|
||||
};
|
||||
};
|
||||
|
||||
buildDarwin =
|
||||
{ pkgs, modules }:
|
||||
inputs.darwin.lib.darwinSystem {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
inputs.mac-app-util.darwinModules.default
|
||||
./platforms/nix-darwin
|
||||
];
|
||||
};
|
||||
|
||||
x86_64-linux-hosts = (import ./hosts nixpkgs).x86_64-linux-hosts;
|
||||
aarch64-linux-hosts = (import ./hosts nixpkgs).aarch64-linux-hosts;
|
||||
aarch64-darwin-hosts = (import ./hosts nixpkgs).aarch64-darwin-hosts;
|
||||
|
||||
in
|
||||
rec {
|
||||
|
||||
# The plan
|
||||
# Import all the host configurations as modules
|
||||
# Setup the modules as nixosModules, homeModules, darwinModules
|
||||
# Create nixosConfigurations using the different pkgs for each system
|
||||
# What to do with home config?
|
||||
|
||||
nixosModules = x86_64-linux-hosts // aarch64-linux-hosts;
|
||||
darwinModules = aarch64-darwin-hosts;
|
||||
|
||||
inherit buildDarwin pkgsBySystem;
|
||||
|
||||
# Contains my full system builds, including home-manager
|
||||
# nixos-rebuild switch --flake .#tempest
|
||||
nixosConfigurations =
|
||||
(builtins.mapAttrs (
|
||||
name: module:
|
||||
buildNixos {
|
||||
pkgs = pkgsBySystem.x86_64-linux;
|
||||
modules = [ module ];
|
||||
}
|
||||
) x86_64-linux-hosts)
|
||||
// (builtins.mapAttrs (
|
||||
name: module:
|
||||
buildNixos {
|
||||
pkgs = pkgsBySystem.aarch64-linux;
|
||||
modules = [ module ];
|
||||
}
|
||||
) aarch64-linux-hosts);
|
||||
|
||||
# Contains my full Mac system builds, including home-manager
|
||||
# darwin-rebuild switch --flake .#lookingglass
|
||||
darwinConfigurations = builtins.mapAttrs (
|
||||
name: module:
|
||||
buildDarwin {
|
||||
pkgs = pkgsBySystem.aarch64-darwin;
|
||||
modules = [ module ];
|
||||
}
|
||||
) aarch64-darwin-hosts;
|
||||
|
||||
# For quickly applying home-manager settings with:
|
||||
# home-manager switch --flake .#tempest
|
||||
homeConfigurations = builtins.mapAttrs (
|
||||
name: module:
|
||||
buildHome {
|
||||
pkgs = pkgsBySystem.x86_64-linux;
|
||||
module = [ module ];
|
||||
}
|
||||
) nixosModules;
|
||||
inherit lib;
|
||||
# inherit buildDarwin pkgsBySystem;
|
||||
#
|
||||
# # Contains my full system builds, including home-manager
|
||||
# # nixos-rebuild switch --flake .#tempest
|
||||
# nixosConfigurations =
|
||||
# (builtins.mapAttrs (
|
||||
# name: module:
|
||||
# buildNixos {
|
||||
# pkgs = pkgsBySystem.x86_64-linux;
|
||||
# modules = [ module ];
|
||||
# }
|
||||
# ) x86_64-linux-hosts)
|
||||
# // (builtins.mapAttrs (
|
||||
# name: module:
|
||||
# buildNixos {
|
||||
# pkgs = pkgsBySystem.aarch64-linux;
|
||||
# modules = [ module ];
|
||||
# }
|
||||
# ) aarch64-linux-hosts);
|
||||
#
|
||||
# # Contains my full Mac system builds, including home-manager
|
||||
# # darwin-rebuild switch --flake .#lookingglass
|
||||
# darwinConfigurations = builtins.mapAttrs (
|
||||
# name: module:
|
||||
# buildDarwin {
|
||||
# pkgs = pkgsBySystem.aarch64-darwin;
|
||||
# modules = [ module ];
|
||||
# }
|
||||
# ) aarch64-darwin-hosts;
|
||||
#
|
||||
# # For quickly applying home-manager settings with:
|
||||
# # home-manager switch --flake .#tempest
|
||||
# homeConfigurations = builtins.mapAttrs (
|
||||
# name: module:
|
||||
# buildHome {
|
||||
# pkgs = pkgsBySystem.x86_64-linux;
|
||||
# module = [ module ];
|
||||
# }
|
||||
# ) nixosModules;
|
||||
|
||||
# Disk formatting, only used once
|
||||
diskoConfigurations = {
|
||||
root = import ./disks/root.nix;
|
||||
root = import ./hosts/x86_64-linux/swan/root.nix;
|
||||
};
|
||||
|
||||
# packages =
|
||||
@ -437,17 +355,21 @@
|
||||
# aarch64-darwin.neovim = neovim "aarch64-darwin";
|
||||
# };
|
||||
|
||||
packages = forAllSystems (system: pkgsBySystem.${system}.nmasur);
|
||||
# Get the custom packages that I have placed under the nmasur namespace
|
||||
packages = lib.forAllSystems (system: lib.pkgsBySystem.${system}.nmasur);
|
||||
|
||||
# Development environments
|
||||
devShells = forAllSystems (system: {
|
||||
default = pkgsBySystem.${system}.nmasur.dotfiles-devshell;
|
||||
devShells = lib.forAllSystems (system: {
|
||||
default = lib.pkgsBySystem.${system}.nmasur.dotfiles-devshell;
|
||||
});
|
||||
|
||||
checks = forAllSystems (
|
||||
checks = lib.forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = lib.overlays;
|
||||
};
|
||||
in
|
||||
{
|
||||
neovim =
|
||||
@ -466,10 +388,13 @@
|
||||
}
|
||||
);
|
||||
|
||||
formatter = forAllSystems (
|
||||
formatter = lib.forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
inherit (lib) overlays;
|
||||
};
|
||||
in
|
||||
pkgs.nixfmt-rfc-style
|
||||
);
|
||||
|
@ -1,22 +0,0 @@
|
||||
# Return a list of all NixOS hosts
|
||||
|
||||
{ nixpkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
in
|
||||
|
||||
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
|
||||
# Get only files ending in default.nix
|
||||
(builtins.filter (name: lib.hasSuffix "default.nix" name))
|
||||
# Remove this file
|
||||
(builtins.filter (name: name != ./default.nix))
|
||||
# Import each host function
|
||||
map
|
||||
(file: {
|
||||
name = builtins.baseNameOf (builtins.dirOf file);
|
||||
value = import file;
|
||||
})
|
||||
# Convert to an attrset of hostname -> host function
|
||||
(builtins.listToAttrs)
|
||||
]
|
@ -61,4 +61,92 @@ lib
|
||||
))
|
||||
];
|
||||
|
||||
# Common overlays to always use
|
||||
overlays = [
|
||||
inputs.nur.overlays.default
|
||||
inputs.nix2vim.overlay
|
||||
] ++ (importOverlays ../overlays);
|
||||
|
||||
# System types to support.
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
# Split system types by operating system
|
||||
linuxSystems = builtins.filter (lib.hasSuffix "linux") supportedSystems;
|
||||
darwinSystems = builtins.filter (lib.hasSuffix "darwin") supportedSystems;
|
||||
|
||||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||
forSystems = systems: lib.genAttrs systems;
|
||||
forAllSystems = lib.genAttrs supportedSystems;
|
||||
|
||||
# { x86_64-linux = { tempest = { settings = ...; }; }; };
|
||||
hosts = forAllSystems (system: defaultFilesToAttrset ../hosts/${system});
|
||||
|
||||
linuxHosts = lib.filterAttrs (name: value: builtins.elem name linuxSystems) hosts;
|
||||
darwinHosts = lib.filterAttrs (name: value: builtins.elem name darwinSystems) hosts;
|
||||
|
||||
# { system -> pkgs }
|
||||
pkgsBySystem = forAllSystems (
|
||||
system:
|
||||
import inputs.nixpkgs {
|
||||
inherit system overlays;
|
||||
config.permittedInsecurePackages = [ "litestream-0.3.13" ];
|
||||
config.allowUnfree = true;
|
||||
}
|
||||
);
|
||||
|
||||
colorscheme = defaultFilesToAttrset ../colorscheme;
|
||||
|
||||
buildHome =
|
||||
{
|
||||
pkgs,
|
||||
modules,
|
||||
}:
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
../platforms/home-manager
|
||||
];
|
||||
};
|
||||
|
||||
buildNixos =
|
||||
{
|
||||
pkgs,
|
||||
modules,
|
||||
specialArgs,
|
||||
}:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.wsl.nixosModules.wsl
|
||||
../platforms/nixos
|
||||
{
|
||||
home-manager.extraSpecialArgs = {
|
||||
hostnames = globals.hostnames;
|
||||
inherit colorscheme;
|
||||
};
|
||||
}
|
||||
];
|
||||
specialArgs = {
|
||||
hostnames = globals.hostnames;
|
||||
};
|
||||
};
|
||||
|
||||
buildDarwin =
|
||||
{ pkgs, modules }:
|
||||
inputs.darwin.lib.darwinSystem {
|
||||
inherit pkgs;
|
||||
modules = modules ++ [
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
inputs.mac-app-util.darwinModules.default
|
||||
./platforms/nix-darwin
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
# Return a list of all overlays
|
||||
|
||||
inputs:
|
||||
|
||||
let
|
||||
lib = inputs.nixpkgs.lib;
|
||||
in
|
||||
|
||||
lib.pipe (lib.filesystem.listFilesRecursive ./.) [
|
||||
# Get only files ending in .nix
|
||||
(builtins.filter (name: lib.hasSuffix ".nix" name))
|
||||
# Remove this file
|
||||
(builtins.filter (name: name != ./default.nix))
|
||||
# Import each overlay file
|
||||
(map (file: (import file) inputs))
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user