Compare commits

...

2 Commits

Author SHA1 Message Date
pegasust 10e59f0420 wip 2022-12-16 06:20:41 +00:00
pegasust 1c29ba92b1 migrate for rearch 2022-12-15 23:33:45 +00:00
36 changed files with 931 additions and 0 deletions

View File

@ -0,0 +1,50 @@
{ config
, proj_root
, myLib
, ...
}:
let
inherit (myLib) fromYaml;
actualConfig = fromYaml (builtins.readFile "${proj_root}//alacritty/alacritty.yml");
cfg = config.base.alacritty;
in
{
options.base.alacritty =
{
font.family = myLib.mkOption {
type = myLib.types.singleLineStr;
default = actualConfig.font.normal.family;
description = ''
The font family for Alacritty
'';
example = "DroidSansMono NF";
};
enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
description = ''
Enables alacritty
'';
example = true;
};
_actualConfig = myLib.mkOption {
type = myLib.types.attrs;
visible = false;
default = actualConfig;
description = "underlying default config";
};
additionalConfigPath = myLib.mkOption {
type = myLib.types.nullOr myLib.types.path;
visible = false;
default = null;
description = "impurely write our alacritty.yml to this path";
};
};
config.programs.alacritty = {
enable = cfg.enable;
settings = myLib.recursiveUpdate actualConfig {
font.normal.family = cfg.font.family;
};
};
}

View File

@ -0,0 +1,28 @@
let
# these are configured to work with home-manager with some mutations that are
# reconfigurable
homeModules = [
./alacritty.nix
./git.nix
./ssh.nix
./shells.nix
./neovim.nix
./home.req.nix
{
config.programs.home-manager.enable = true;
}
];
# These are the modules that should be used only in nixosConfigurations
# since it relies on root permission to run
serviceModules = [
./gitea.service.nix
./vault.service.nix
./tailscale.service.nix
];
allModules = homeModules ++ serviceModules;
in
{
mkModuleArgs = import ./mkModuleArgs.nix;
modules = allModules;
inherit homeModules serviceModules;
}

81
nix/configModule/git.nix Normal file
View File

@ -0,0 +1,81 @@
{ config
, myLib
, ...
}:
let
cfg = config.base.git;
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
in
{
options.base.git = {
aliases = myLib.mkOption {
type = myLib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
};
name = myLib.mkOption {
type = myLib.types.str;
default = "Pegasust";
description = "Git username that appears on commits";
example = "Pegasust";
};
email = myLib.mkOption {
type = myLib.types.str;
default = "pegasucksgg@gmail.com";
example = "peagsucksgg@gmail.com";
description = "Git email that appears on commits";
};
ignores = myLib.mkOption {
type = myLib.types.listOf myLib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
];
description = ''
.gitignore patterns that are applied in every repository.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = myLib.mkOption {
type = myLib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
};
};
# TODO : anyway to override configuration?
config.programs.git = lib.mkIf cfg.enable {
inherit (cfg) ignores;
enable = true;
userName = cfg.name;
userEmail = cfg.email;
aliases = baseAliases // cfg.aliases;
extraConfig = {
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
};
lfs.enable = true;
};
}

View File

View File

@ -0,0 +1,18 @@
{ config, pkgs, lib, ... }@input:
let
cfg = config.base.home;
types = lib.types;
in
{
options.base.home = {
packages = lib.mkOption {
type = types.listOf types.package;
description = "Addtional packages that are available at user level";
default = [ ];
example = [ pkgs.python310Full pkgs.ripgrep ];
};
user = lib.mkOption {
};
};
}

View File

View File

@ -0,0 +1,89 @@
# Configurations for shell stuffs.
# Should probably be decoupled even more
{ config
, proj_root
, myLib
, ...
}:
let cfg = config.base.shells;
in
{
options.base.shells = {
enable = myLib.mkOption {
type = myLib.types.bool;
description = "Enable umbrella shell configuration";
default = true;
example = false;
};
# TODO: Support shell-specific init
shellInitExtra = myLib.mkOption {
type = myLib.types.str;
description = "Extra shell init. The syntax should be sh-compliant";
default = "";
example = ''
# X11 support for WSL
export DISPLAY=$(ip route list default | awk '{print $3}'):0
export LIBGL_ALWAYS_INDIRECT=1
'';
};
shellAliases = myLib.mkOption {
type = myLib.types.attrs;
description = "Shell command aliases";
default = { };
example = {
nixGL = "nixGLIntel";
};
};
};
config = myLib.mkIf cfg.enable {
xdg.configFile."starship.toml".source = "${proj_root}//starship/starship.toml";
# nix: Propagates the environment with packages and vars when enter (children of)
# a directory with shell.nix-compatible and .envrc
programs.direnv = {
enable = true;
nix-direnv.enable = true;
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
};
# z <path> as smarter cd
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
programs.tmux = {
enable = true;
extraConfig = builtins.readFile "${proj_root}/tmux/tmux.conf";
};
programs.exa = {
enable = true;
enableAliases = true;
};
programs.starship = {
enable = true;
enableZshIntegration = true;
};
programs.fzf.enable = true;
programs.bash = {
enable = true;
enableCompletion = true;
initExtra = cfg.shellInitExtra or "";
};
programs.zsh = {
enable = true;
enableCompletion = true;
enableAutosuggestions = true;
shellAliases = {
nix-rebuild = "sudo nixos-rebuild switch";
hm-switch = "home-manager switch --flake";
} // (cfg.shellAliases or { });
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
oh-my-zsh = {
enable = true;
plugins = [ "git" "sudo" "command-not-found" "gitignore" "ripgrep" "rust" ];
};
initExtra = cfg.shellInitExtra or "";
};
};
}

23
nix/configModule/ssh.nix Normal file
View File

@ -0,0 +1,23 @@
{ config
, proj_root
, myLib
, ...
}:
let cfg = config.base.ssh;
in
{
options.base.ssh.enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
example = false;
description = ''
Enables SSH
'';
};
config.programs.ssh = {
inherit (cfg) enable;
forwardAgent = true;
extraConfig = builtins.readFile "${proj_root}/ssh/config";
};
}

View File

View File

View File

1
nix/default.nix Normal file
View File

@ -0,0 +1 @@
import

216
nix/flake.lock Normal file
View File

@ -0,0 +1,216 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils-plus": {
"inputs": {
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1657226504,
"narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1670970889,
"narHash": "sha256-TWJo3/X3Q3r+HeX16QN4FE6ddBpGtAboymSEF+4Nnc0=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "e412025fffdcd6219ddd21c65d9a1b90005ce508",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixgl": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1661367362,
"narHash": "sha256-Qc8MXcV+YCPREu8kk6oggk23ZBKLqeQRAIsLbHEviPE=",
"owner": "guibou",
"repo": "nixGL",
"rev": "7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae",
"type": "github"
},
"original": {
"owner": "guibou",
"repo": "nixGL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1660551188,
"narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1671021324,
"narHash": "sha256-MDB6TncBzBCvAgQmjNn14VIaO5wdbxExp8NGP990Udk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "62433a4892603c523840a67e50b6631c37adb928",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils-plus": "flake-utils-plus",
"home-manager": "home-manager",
"nixgl": "nixgl",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1671071423,
"narHash": "sha256-zUldhyWANdgko+lqQuB1Eee7TyYya1KiOS0SCd/Y268=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "684659b7ca903e512a421bc6ade689fb26e509b4",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

57
nix/flake.nix Normal file
View File

@ -0,0 +1,57 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# useful only when packaging, not really within config zone
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus";
nixgl.url = "github:guibou/nixGL";
rust-overlay.url = "github:oxalica/rust-overlay";
# Allows default.nix to call onto flake.nix. Useful for nix eval and automations
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
# naersk.url = "gihub:nix-community/naersk";
};
outputs = { nixpkgs, nixgl, rust-overlay, flake-utils-plus, ... } @ inputs:
{
# HACK:
# this is to get multiple platforms support for home-manager
# see https://github.com/nix-community/home-manager/issues/3075#issuecomment-1330661815
# Expect this to change quite in some near future
# packages.linux_something.{nixosConfigurations,homeConfigurations}
packages = builtins.foldl'
(so_far: system: (
let
# init config
overlays = [ nixgl.overlay rust-overlay.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
_lib = pkgs.lib;
lib = _lib.recursiveUpdate _lib import ./lib { inherit pkgs; };
configModule = import ./configModule;
moduleInputs = lib.recursiveUpdate inputs { inherit pkgs lib configModule; };
# module collecting
hosts = import ./hosts moduleInputs;
users = import ./users moduleInputs;
exportSystems = { nixosConfigurations, homeConfigurations }@_configs: {
packages.${system} = {
inherit (_configs) nixosConfigurations homeConfigurations;
};
};
in
so_far // {
${system} = {
inherit pkgs lib overlays;
nixosConfigurations = hosts;
homeConfigurations = users;
};
}
))
{ }
flake-utils-plus.lib.defaultSystems;
};
}

View File

@ -0,0 +1,80 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
## NOTE: These filesystems are mounted by a wrapper script from nix-wsl
# fileSystems."/" =
# {
# device = "/dev/sdc";
# fsType = "ext4";
# };
#
# fileSystems."/mnt/wsl" =
# {
# device = "tmpfs";
# fsType = "tmpfs";
# };
#
# fileSystems."/mnt/wsl/docker-desktop/shared-sockets/guest-services" =
# {
# device = "none";
# fsType = "tmpfs";
# };
#
# fileSystems."/usr/lib/wsl/drivers" =
# {
# device = "drivers";
# fsType = "drvfs";
# };
#
# fileSystems."/usr/lib/wsl/lib" =
# {
# device = "lib";
# fsType = "drvfs";
# };
fileSystems."/mnt/c" =
{
device = "C:";
fsType = "drvfs";
};
fileSystems."/mnt/d" =
{
device = "D:";
fsType = "drvfs";
};
fileSystems."/mnt/f" =
{
device = "F:";
fsType = "drvfs";
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.bond0.useDHCP = lib.mkDefault true;
# networking.interfaces.bonding_masters.useDHCP = lib.mkDefault true;
# networking.interfaces.dummy0.useDHCP = lib.mkDefault true;
# networking.interfaces.eth0.useDHCP = lib.mkDefault true;
# networking.interfaces.sit0.useDHCP = lib.mkDefault true;
# networking.interfaces.tunl0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1,18 @@
{ lib # require extended lib
, config
, pkgs
, modulePaths
, ...
}@inputs:
# Yields {nix = import ./nyx.nix inputs; ...}
# TODO: use something that can detect .nix into a list for auto adding. Remember to filter out default.nix
lib.exportWithInputs (
[
./nyx.nix
./Felia.nix
./lizzi.nix
./prince.nix
]
inputs
)

View File

View File

@ -0,0 +1,49 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelParams = [ "console=ttyS0,19200n8" ];
boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial;
terminal_output serial
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems = {
"/" = {
device = "/dev/sda";
fsType = "ext4";
};
# Assume Linode volume "gitea" exists, mount it to '/gitea"'
"/gitea" = {
device = "/dev/disk/by-id/scsi-0Linode_Volume_gitea";
fsType = "ext4";
};
};
swapDevices =
[{ device = "/dev/sdb"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1,42 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader.grub.extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1
terminal_input serial;
terminal_output serial;
'';
boot.loader.grub.forceInstall = true;
boot.loader.grub.device = "nodev";
boot.loader.timeout = 10;
fileSystems."/" =
{ device = "/dev/sda";
fsType = "ext4";
};
swapDevices =
[ { device = "/dev/sdb"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s5.useDHCP = lib.mkDefault true;
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -0,0 +1 @@
inputs: {}

9
nix/hosts/default.nix Normal file
View File

@ -0,0 +1,9 @@
{ flake-utils-plus
, lib # extended lib from ../lib
, ...
} @inputs:
lib.exportWithInputs [
./prince
./hwtr
] inputs

View File

2
nix/hosts/hwtr/nix.conf Normal file
View File

@ -0,0 +1,2 @@
accept-flake-config = true
experimental-features = nix-command flakes

View File

View File

20
nix/lib/default.nix Normal file
View File

@ -0,0 +1,20 @@
# Contains all of the utilities to help build this monorepo
# NOTE: lib is evaluated after overlays, but before import of mypkgs
# since mypkgs is dependent on ./lib
# In the future, if we need to develop utilities on top of mypkgs,
# use public_lib instead
{ pkgs
, lib ? pkgs.lib
, ...
}@flake_import:
let
moduleUtils = import ./moduleUtils flake_import;
inherit (moduleUtils.exportWithInputs [ ./serde ] flake_import) serde;
recursiveUpdate = lib.recursiveUpdate;
in
recursiveUpdate (recursiveUpdate pkgs.lib lib) {
fromYaml = serde.fromYaml;
fromYamlPath = serde.fromYamlPath;
inherit (moduleUtils) exportWithInputs;
}

24
nix/lib/moduleUtils.nix Normal file
View File

@ -0,0 +1,24 @@
{ flake-utils-plus
, lib
, ...
}: {
# exportWithInputs [./a.nix ./b.nix] {my = "inputs";}
# -> {a = import ./a.nix {my = "inputs";}, b = import ./b.nix {my = "inputs";}}
exportWithInputs = modules: inputs: (
lib.mapAttrs (name: value: (value inputs))
(flake-utils-plus.lib.exportModules modules));
mkModuleArgs =
# This shows the config fields that these modules are expected to have
# usage: [extra]specialArgs = mkModuleArgs {pkgs, lib,...} @ inputs
# Note that mkModuleArgs also recursively merges `inputs`
{ pkgs, lib ? pkgs.lib, ... }@inputs:
let
recursiveUpdate = lib.recursiveUpdate;
_lib = recursiveUpdate lib (import ../../lib { inherit pkgs lib; });
in
# TODO: Unpollute inputs
recursiveUpdate inputs {
proj_root = builtins.toString ./../..;
myLib = _lib;
};
}

29
nix/lib/serde/default.nix Normal file
View File

@ -0,0 +1,29 @@
# Takes care of serializing and deserializing to some formats
# Blame: Pegasust<pegasucksgg@gmail.com>
# TODO: Add to* formats from pkgs.formats.*
{ pkgs
, lib
, ...
} @ inputs:
let
yamlToJsonDrv = yamlContent: outputPath: pkgs.callPackage
({ runCommand }:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
runCommand outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# run yq which outputs '.' (no filter) on file at yamlPath
# note that $out is passed onto the bash/sh script for execution
''
echo "$yamlContent" | yq >$out
'')
{ };
in {
# Takes in a yaml string and produces a derivation with translated JSON at $outputPath
# similar to builtins.fromJSON, turns a YAML string to nix attrset
fromYaml = yamlContent: builtins.fromJSON (builtins.readFile (yamlToJsonDrv yamlContent "any_output.json"));
fromYamlPath = yamlPath: builtins.fromJSON (
builtins.readFile (
yamlToJsonDrv (
builtins.readFile yamlPath)
"any-output.json"));
# TODO: fromToml?
}

9
nix/pkgs/cargo-bacon.nix Normal file
View File

@ -0,0 +1,9 @@
{ pkgs
, lib
, naersk
,...
}@pkgs_input: {
deriv = pkgs.rustPlatform.buildRustPackage rec {
pname = "bacon";
};
}

14
nix/pkgs/default.nix Normal file
View File

@ -0,0 +1,14 @@
# This module aims to be merge (not inject/override) with top-level pkgs to provide
# personalized/custom packages
# For utility functions that aids with development of this whole monorepo,
# go into ../lib.
{ pkgs
, lib # extended lib from ../lib
, naersk # rust packages
, ...
}@pkgs_input:
lib.exportWithInputs [
./nixgl
./neovim
./cargo-bacon
] pkgs_input

1
nix/pkgs/neovim.nix Normal file
View File

@ -0,0 +1 @@
inputs: null

1
nix/pkgs/nixgl.nix Normal file
View File

@ -0,0 +1 @@
inputs: null

10
nix/users/default.nix Normal file
View File

@ -0,0 +1,10 @@
{ home-manager
, lib # extended lib from ../lib
, pkgs
, ... }@inputs:
lib.exportWithInputs [
./hwtr
./prince
./hungtr
] inputs

31
nix/users/hungtr.nix Normal file
View File

@ -0,0 +1,31 @@
{ home-manager, lib, pkgs, configModule, ... }@inputs: {
# end result: homeConfigurations.hwtr = home-manager...
homeConfig = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = configModule.homeModules ++ [
{
base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font";
base.shells = {
shellAliases = {
nixGL = "nixGLIntel";
};
};
users.users.hungtr = {
isNormalUser = true;
home = "/home/hungtr";
description = "pegasust/hungtr";
extraGroups = [ "wheel" "networkmanager" ];
};
}
];
extraSpecialArgs = lib.mkModuleArgs {
inherit pkgs;
myHome = {
packages = [
pkgs.nixgl.nixGLIntel
pkgs.postman
];
};
};
};
}

28
nix/users/hwtr.nix Normal file
View File

@ -0,0 +1,28 @@
{ home-manager, lib, pkgs }@inputs: {
# end result: homeConfigurations.hwtr = home-manager...
homeConfig = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = base.modules ++ [
./home.req.nix
{
base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font";
base.shells = {
shellAliases = {
nixGL = "nixGLIntel";
};
};
}
];
extraSpecialArgs = lib.mkModuleArgs {
inherit pkgs;
myHome = {
username = "hwtr";
homeDirectory = "/home/hwtr";
packages = [
pkgs.nixgl.nixGLIntel
pkgs.postman
];
};
};
};
}

0
nix/users/prince.nix Normal file
View File