refactor: use $FLAKE instead of /home/mainUser...
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-03-26 13:55:55 -04:00
parent 0fd7817932
commit 3f288f3e8f
8 changed files with 25 additions and 19 deletions

View file

@ -9,6 +9,9 @@ for UI. Click on
[this](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/modules/ags) [this](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/modules/ags)
to see my configuration. to see my configuration.
I'm also a victim of Stockholm syndrome at this point and make my scripts
in TypeScript because it's the scripting language I am most comfortable with.
## About ## About
### General ### General
@ -21,7 +24,7 @@ explained
### Flake Location ### Flake Location
This git repo will always be located at `/home/${mainUser}/.nix` This git repo will always be located at `$FLAKE` (`config.environment.variables.FLAKE`)
and symlinked to `/etc/nixos` to have everything where NixOS tools and symlinked to `/etc/nixos` to have everything where NixOS tools
expect things to be. expect things to be.
@ -29,6 +32,9 @@ ie.
```bash ```bash
sudo rm -r /etc/nixos sudo rm -r /etc/nixos
echo "$FLAKE" # /home/matt/.nix
sudo ln -sf /home/matt/.nix /etc/nixos sudo ln -sf /home/matt/.nix /etc/nixos
``` ```

View file

@ -1,6 +1,7 @@
{ {
config, config,
home-manager, home-manager,
lib,
nh, nh,
nix-melt, nix-melt,
nur, nur,
@ -64,7 +65,7 @@
extraArgs = "--keep-since 30d"; extraArgs = "--keep-since 30d";
}; };
}; };
environment.variables.FLAKE = "/home/matt/.nix"; environment.variables.FLAKE = lib.mkDefault "/home/matt/.nix";
services = { services = {
fwupd.enable = true; fwupd.enable = true;

View file

@ -1,6 +1,6 @@
# Check git status of nix configs # Check git status of nix configs
fetchNix() {( fetchNix() {(
cd ~/.nix || exit 1 cd "$FLAKE" || exit 1
git fetch --all --quiet git fetch --all --quiet
GIT=$(git -c color.status=always status | GIT=$(git -c color.status=always status |
grep -v -e "On branch" \ grep -v -e "On branch" \

View file

@ -1,10 +1,4 @@
{ {pkgs, ...}: {
config,
pkgs,
...
}: let
inherit (config.vars) mainUser;
in {
programs = { programs = {
git = { git = {
enable = true; enable = true;
@ -75,9 +69,10 @@ in {
runtimeInputs = [git]; runtimeInputs = [git];
text = '' text = ''
DIR=''${1:-"/home/${mainUser}/.nix"} DIR=''${1:-"$FLAKE"}
cd "$DIR" || exit 1
cd "$DIR"
git add flake.lock git add flake.lock
git commit -m 'chore: update flake.lock' git commit -m 'chore: update flake.lock'
git push git push

View file

@ -5,6 +5,7 @@
}: { }: {
options.vars = let options.vars = let
inherit (lib) mkOption types; inherit (lib) mkOption types;
flakeDir = config.environment.variables.FLAKE;
cfg = config.vars; cfg = config.vars;
in { in {
mainUser = mkOption { mainUser = mkOption {
@ -49,7 +50,7 @@
configDir = mkOption { configDir = mkOption {
type = types.str; type = types.str;
default = "/home/${cfg.mainUser}/.nix/devices/${cfg.hostName}/config"; default = "${flakeDir}/devices/${cfg.hostName}/config";
description = '' description = ''
The path to where most of the devices' configs are in the .nix folder The path to where most of the devices' configs are in the .nix folder
''; '';
@ -61,7 +62,7 @@
The name of the main monitor used for Hyprland The name of the main monitor used for Hyprland
and Regreet which also uses Hyprland and Regreet which also uses Hyprland
''; '';
# This is to allow a bash script to know wether this value exists # This is to allow a bash script to know whether this value exists
default = "null"; default = "null";
}; };

View file

@ -38,5 +38,6 @@ readdir(DIR, (_, files) => {
'--overwrite', '--overwrite',
]; ];
// TODO: actually call the command
console.log(cmd); console.log(cmd);
}); });

View file

@ -7,6 +7,7 @@
}: let }: let
inherit (config.vars) mainUser hostName; inherit (config.vars) mainUser hostName;
flakeDir = config.environment.variables.FLAKE;
isTouchscreen = config.hardware.sensor.iio.enable; isTouchscreen = config.hardware.sensor.iio.enable;
in { in {
# Enable pam for ags and astal # Enable pam for ags and astal
@ -28,11 +29,11 @@ in {
inherit (lib) optionals; inherit (lib) optionals;
astalTypes = config.home.file.".local/share/io.Aylur.Astal/types"; astalTypes = config.home.file.".local/share/io.Aylur.Astal/types";
astalConfigDir = ".nix/modules/ags/astal"; astalConfigDir = ".nix/modules/ags/astal"; # FIXME: figure out way to use $FLAKE
# https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69 # https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69
agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types"; agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types";
agsConfigDir = ".nix/modules/ags/config"; agsConfigDir = ".nix/modules/ags/config"; # FIXME: figure out way to use $FLAKE
configJs = configJs =
/* /*
@ -57,11 +58,11 @@ in {
home = { home = {
file = file =
{ {
".config/astal".source = symlink /home/${mainUser}/.nix/modules/ags/astal; ".config/astal".source = symlink "${flakeDir}/modules/ags/astal";
"${astalConfigDir}/types".source = astalTypes.source; "${astalConfigDir}/types".source = astalTypes.source;
"${astalConfigDir}/config.js".text = configJs; "${astalConfigDir}/config.js".text = configJs;
".config/ags".source = symlink /home/${mainUser}/.nix/modules/ags/config; ".config/ags".source = symlink "${flakeDir}/modules/ags/config";
"${agsConfigDir}/types".source = agsTypes.source; "${agsConfigDir}/types".source = agsTypes.source;
"${agsConfigDir}/config.js".text = configJs; "${agsConfigDir}/config.js".text = configJs;
} }

View file

@ -6,6 +6,7 @@
}: let }: let
inherit (lib) makeLibraryPath optionalString; inherit (lib) makeLibraryPath optionalString;
inherit (config.vars) mainUser; inherit (config.vars) mainUser;
flakeDir = config.environment.variables.FLAKE;
in { in {
imports = [../dolphin.nix]; imports = [../dolphin.nix];
@ -20,7 +21,7 @@ in {
({config, ...}: let ({config, ...}: let
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
configDir = "/home/${mainUser}/.nix/modules/hyprland/config"; configDir = "${flakeDir}/modules/hyprland/config";
in { in {
xdg.configFile = { xdg.configFile = {
"dolphinrc".source = symlink "${configDir}/dolphinrc"; "dolphinrc".source = symlink "${configDir}/dolphinrc";