mirror of
https://github.com/nmasur/dotfiles
synced 2025-03-14 16:57:06 +00:00
coalescing code for imports
This commit is contained in:
parent
90fd9f54a7
commit
1eae89b8ab
20
colorscheme/default.nix
Normal file
20
colorscheme/default.nix
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# 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)
|
||||||
|
|
||||||
|
]
|
12
flake.nix
12
flake.nix
@ -222,9 +222,6 @@
|
|||||||
fullName = "Noah Masur";
|
fullName = "Noah Masur";
|
||||||
gitName = fullName;
|
gitName = fullName;
|
||||||
gitEmail = "7386960+nmasur@users.noreply.github.com";
|
gitEmail = "7386960+nmasur@users.noreply.github.com";
|
||||||
mail.server = "noahmasur.com";
|
|
||||||
mail.imapHost = "imap.purelymail.com";
|
|
||||||
mail.smtpHost = "smtp.purelymail.com";
|
|
||||||
dotfilesRepo = "https://github.com/nmasur/dotfiles";
|
dotfilesRepo = "https://github.com/nmasur/dotfiles";
|
||||||
hostnames = {
|
hostnames = {
|
||||||
audiobooks = "read.${baseName}";
|
audiobooks = "read.${baseName}";
|
||||||
@ -253,16 +250,12 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
colorscheme = import ./colorscheme;
|
||||||
|
|
||||||
# Common overlays to always use
|
# Common overlays to always use
|
||||||
overlays = [
|
overlays = [
|
||||||
inputs.nur.overlays.default
|
inputs.nur.overlays.default
|
||||||
inputs.nix2vim.overlay
|
inputs.nix2vim.overlay
|
||||||
# inputs.jujutsu.overlays.default # Fix: https://github.com/martinvonz/jj/issues/4784
|
|
||||||
# (import ./overlays/neovim-plugins.nix inputs)
|
|
||||||
# (import ./overlays/tree-sitter.nix inputs)
|
|
||||||
# (import ./overlays/mpv-scripts.nix inputs)
|
|
||||||
# (import ./overlays/nextcloud-apps.nix inputs)
|
|
||||||
# (import ./overlays/pkgs.nix)
|
|
||||||
] ++ (import ./overlays inputs);
|
] ++ (import ./overlays inputs);
|
||||||
|
|
||||||
# System types to support.
|
# System types to support.
|
||||||
@ -308,6 +301,7 @@
|
|||||||
{
|
{
|
||||||
home-manager.extraSpecialArgs = {
|
home-manager.extraSpecialArgs = {
|
||||||
hostnames = globals.hostnames;
|
hostnames = globals.hostnames;
|
||||||
|
inherit colorscheme;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -29,7 +29,7 @@ rec {
|
|||||||
work.enable = true;
|
work.enable = true;
|
||||||
experimental.enable = true;
|
experimental.enable = true;
|
||||||
};
|
};
|
||||||
nmasur.presets.programs.git = {
|
nmasur.presets.programs.git-work.work = {
|
||||||
name = "Noah-Masur_1701";
|
name = "Noah-Masur_1701";
|
||||||
email = "${nmasur.settings.username}@take2games.com";
|
email = "${nmasur.settings.username}@take2games.com";
|
||||||
};
|
};
|
||||||
|
@ -31,14 +31,11 @@ rec {
|
|||||||
developer.enable = true;
|
developer.enable = true;
|
||||||
experimental.enable = true;
|
experimental.enable = true;
|
||||||
};
|
};
|
||||||
nmasur.presets.services.mbsync = {
|
|
||||||
user = nmasur.settings.username;
|
|
||||||
server = "noahmasur.com";
|
|
||||||
};
|
|
||||||
home.stateVersion = "23.05";
|
home.stateVersion = "23.05";
|
||||||
};
|
};
|
||||||
|
|
||||||
system.stateVersion = "23.05";
|
system.stateVersion = "23.05";
|
||||||
|
|
||||||
# Not sure what's necessary but too afraid to remove anything
|
# Not sure what's necessary but too afraid to remove anything
|
||||||
boot.initrd.availableKernelModules = [
|
boot.initrd.availableKernelModules = [
|
||||||
"nvme"
|
"nvme"
|
||||||
|
64
lib/default.nix
Normal file
64
lib/default.nix
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
inputs:
|
||||||
|
|
||||||
|
let
|
||||||
|
lib = inputs.nixpkgs.lib;
|
||||||
|
in
|
||||||
|
|
||||||
|
lib
|
||||||
|
// rec {
|
||||||
|
|
||||||
|
filesInDirectoryWithSuffix =
|
||||||
|
directory: suffix:
|
||||||
|
lib.pipe (lib.filesystem.listFilesRecursive directory) [
|
||||||
|
# Get only files ending in .nix
|
||||||
|
(builtins.filter (name: lib.hasSuffix suffix name))
|
||||||
|
];
|
||||||
|
|
||||||
|
# Returns all files ending in .nix for a directory
|
||||||
|
nixFiles = directory: filesInDirectoryWithSuffix directory ".nix";
|
||||||
|
|
||||||
|
# Returns all files ending in default.nix for a directory
|
||||||
|
defaultFiles = directory: filesInDirectoryWithSuffix directory "default.nix";
|
||||||
|
|
||||||
|
# Imports all files in a directory and passes inputs
|
||||||
|
importOverlays =
|
||||||
|
directory:
|
||||||
|
lib.pipe (nixFiles directory) [
|
||||||
|
# Import each overlay file
|
||||||
|
(map (file: (import file) inputs))
|
||||||
|
];
|
||||||
|
|
||||||
|
# Import default files as attrset with keys provided by parent directory
|
||||||
|
defaultFilesToAttrset =
|
||||||
|
directory:
|
||||||
|
lib.pipe (defaultFiles directory) [
|
||||||
|
# Import each file
|
||||||
|
(map (file: {
|
||||||
|
name = builtins.baseNameOf (builtins.dirOf file);
|
||||||
|
value = import file;
|
||||||
|
}))
|
||||||
|
# Convert to an attrset of parent dir name -> file
|
||||||
|
(builtins.listToAttrs)
|
||||||
|
];
|
||||||
|
|
||||||
|
# [ package1/package.nix package2/package.nix package2/hello.sh ]
|
||||||
|
buildPkgsFromDirectoryAndPkgs =
|
||||||
|
directory: pkgs:
|
||||||
|
lib.pipe (filesInDirectoryWithSuffix directory "package.nix") [
|
||||||
|
|
||||||
|
# Apply callPackage to create a derivation
|
||||||
|
# Must use final.callPackage to avoid infinite recursion
|
||||||
|
# [ package1.drv package2.drv ]
|
||||||
|
(builtins.map (name: pkgs.callPackage name { }))
|
||||||
|
|
||||||
|
# Convert the list to an attrset with keys from pname or name attr
|
||||||
|
# { package1 = package1.drv, package2 = package2.drv }
|
||||||
|
(builtins.listToAttrs (
|
||||||
|
map (v: {
|
||||||
|
name = v."pname" or v."name";
|
||||||
|
value = v;
|
||||||
|
})
|
||||||
|
))
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
@ -27,10 +27,12 @@ in
|
|||||||
name = lib.mkOption {
|
name = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Name to use for personal git commits";
|
description = "Name to use for personal git commits";
|
||||||
|
default = config.nmasur.presets.programs.git.name;
|
||||||
};
|
};
|
||||||
email = lib.mkOption {
|
email = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Email to use for personal git commits";
|
description = "Email to use for personal git commits";
|
||||||
|
default = config.nmasur.presets.programs.git.email;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.nmasur.settings) fullName hostnames;
|
inherit (config.nmasur.settings) username fullName hostnames;
|
||||||
cfg = config.nmasur.presets.services.mbsync;
|
cfg = config.nmasur.presets.services.mbsync;
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -17,10 +17,12 @@ in
|
|||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "User name for the email address.";
|
description = "User name for the email address.";
|
||||||
|
default = username;
|
||||||
};
|
};
|
||||||
server = lib.mkOption {
|
server = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Server name for the email address.";
|
description = "Server name for the email address.";
|
||||||
|
default = hostnames.mail;
|
||||||
};
|
};
|
||||||
imapHost = lib.mkOption {
|
imapHost = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ lib, colorscheme, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -11,7 +11,7 @@
|
|||||||
colors = lib.mkOption {
|
colors = lib.mkOption {
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrs;
|
||||||
description = "Base16 color scheme.";
|
description = "Base16 color scheme.";
|
||||||
default = (import ../../colorscheme/gruvbox).dark;
|
default = colorscheme.gruvbox.dark;
|
||||||
};
|
};
|
||||||
mode = lib.mkOption {
|
mode = lib.mkOption {
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
globals,
|
hostnames,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ in
|
|||||||
# Allow web traffic to Caddy
|
# Allow web traffic to Caddy
|
||||||
nmasur.presets.services.caddy.routes = [
|
nmasur.presets.services.caddy.routes = [
|
||||||
{
|
{
|
||||||
match = [ { host = [ globals.hostnames.audiobooks ]; } ];
|
match = [ { host = [ hostnames.audiobooks ]; } ];
|
||||||
handle = [
|
handle = [
|
||||||
{
|
{
|
||||||
handler = "reverse_proxy";
|
handler = "reverse_proxy";
|
||||||
@ -41,7 +41,7 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
# Configure Cloudflare DNS to point to this machine
|
# Configure Cloudflare DNS to point to this machine
|
||||||
services.cloudflare-dyndns.domains = [ globals.hostnames.audiobooks ];
|
services.cloudflare-dyndns.domains = [ hostnames.audiobooks ];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
{ lib, hostnames, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
hostnames,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
options.nmasur.settings = {
|
options.nmasur.settings = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user