mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-27 10:26:58 +02:00
feat: simplify flake.nix
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
{config, ...}: let
|
||||
d = config.xdg.dataHome;
|
||||
c = config.xdg.configHome;
|
||||
cache = config.xdg.cacheHome;
|
||||
in
|
||||
rec {
|
||||
in rec {
|
||||
# add environment variables
|
||||
systemd.user.sessionVariables = {
|
||||
# clean up ~
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
# Linux Only Packages, not available on Darwin
|
||||
home.packages = with pkgs; [
|
||||
btop # replacement of htop/nmon
|
||||
@@ -13,7 +10,7 @@
|
||||
# misc
|
||||
libnotify
|
||||
wireguard-tools # manage wireguard vpn manually, via wg-quick
|
||||
|
||||
|
||||
# need to run `conda-install` before using it
|
||||
# need to run `conda-shell` before using command `conda`
|
||||
# conda is not available for MacOS
|
||||
@@ -30,7 +27,7 @@
|
||||
ethtool
|
||||
pciutils # lspci
|
||||
usbutils # lsusb
|
||||
hdparm # for disk performance, command
|
||||
hdparm # for disk performance, command
|
||||
dmidecode # a tool that reads information about your system's hardware from the BIOS according to the SMBIOS/DMI standard
|
||||
];
|
||||
|
||||
@@ -42,5 +39,4 @@
|
||||
services = {
|
||||
# syncthing.enable = true;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
{ username, ... }: {
|
||||
imports = [
|
||||
../base/desktop
|
||||
|
||||
@@ -13,12 +11,9 @@
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = let
|
||||
name = "ryan";
|
||||
in
|
||||
{
|
||||
username = name;
|
||||
homeDirectory = "/home/${name}";
|
||||
home = {
|
||||
username = username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
{ username, ... }: {
|
||||
imports = [
|
||||
../base/desktop
|
||||
|
||||
@@ -9,16 +7,13 @@
|
||||
./desktop
|
||||
|
||||
./i3
|
||||
];
|
||||
];
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = let
|
||||
name = "ryan";
|
||||
in
|
||||
{
|
||||
username = name;
|
||||
homeDirectory = "/home/${name}";
|
||||
home = {
|
||||
username = username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
# creative
|
||||
# blender # 3d modeling
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
imports = [
|
||||
./creative.nix
|
||||
./immutable-file.nix
|
||||
@@ -10,7 +9,7 @@
|
||||
|
||||
home.packages = with pkgs; [
|
||||
# GUI apps
|
||||
insomnia # REST client
|
||||
insomnia # REST client
|
||||
wireshark # network analyzer
|
||||
|
||||
# e-book viewer(.epub/.mobi/...)
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
##############################################################################################
|
||||
#
|
||||
# Provide a option `home.immutable-file`, it works like `home.file` but make the generated file immutable.
|
||||
#
|
||||
# Copy from https://github.com/iosmanthus/nixos-config/blob/349917b/modules/immutable-file.nix
|
||||
#
|
||||
# this module use the `chattr +i` to make the file immutable, `i` indicates `immutable`,
|
||||
# this module use the `chattr +i` to make the file immutable, `i` indicates `immutable`,
|
||||
# it's a i-node flags only works on Linux.
|
||||
#
|
||||
#
|
||||
# TODO not used yet, need to test it.
|
||||
#
|
||||
#
|
||||
##############################################################################################
|
||||
|
||||
with lib;
|
||||
let
|
||||
with lib; let
|
||||
cfg = config.home.immutable-file;
|
||||
immutableFileOpts = { ... }: {
|
||||
immutableFileOpts = {...}: {
|
||||
options = {
|
||||
src = mkOption {
|
||||
type = types.path;
|
||||
@@ -44,21 +42,24 @@ let
|
||||
sudo cp $2 $1
|
||||
sudo chattr +i $1
|
||||
'';
|
||||
in
|
||||
{
|
||||
in {
|
||||
options.home.immutable-file = mkOption {
|
||||
type = with types; attrsOf (submodule immutableFileOpts);
|
||||
default = { };
|
||||
default = {};
|
||||
};
|
||||
|
||||
config = mkIf (cfg != { }) {
|
||||
home.activation = mapAttrs'
|
||||
(name: { src, dst }:
|
||||
config = mkIf (cfg != {}) {
|
||||
home.activation =
|
||||
mapAttrs'
|
||||
(name: {
|
||||
src,
|
||||
dst,
|
||||
}:
|
||||
nameValuePair
|
||||
"make-immutable-${name}"
|
||||
(lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
${mkImmutableFile} ${dst} ${src}
|
||||
''))
|
||||
"make-immutable-${name}"
|
||||
(lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
${mkImmutableFile} ${dst} ${src}
|
||||
''))
|
||||
cfg;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{ pkgs
|
||||
, config
|
||||
, ...
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
# media - control and enjoy audio/video
|
||||
{
|
||||
@@ -23,8 +24,8 @@
|
||||
programs = {
|
||||
mpv = {
|
||||
enable = true;
|
||||
defaultProfiles = [ "gpu-hq" ];
|
||||
scripts = [ pkgs.mpvScripts.mpris ];
|
||||
defaultProfiles = ["gpu-hq"];
|
||||
scripts = [pkgs.mpvScripts.mpris];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{ pkgs
|
||||
, ...
|
||||
}: {
|
||||
{pkgs, ...}: {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
@@ -35,7 +33,7 @@
|
||||
Host gtr5
|
||||
HostName 192.168.5.172
|
||||
Port 22
|
||||
|
||||
|
||||
Host um560
|
||||
HostName 192.168.5.173
|
||||
Port 22
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
|
||||
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
|
||||
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
|
||||
# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
|
||||
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
|
||||
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
|
||||
# https://www.freedesktop.org/wiki/Specifications/
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
home.packages = with pkgs; [
|
||||
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
|
||||
xdg-user-dirs
|
||||
@@ -15,68 +18,64 @@
|
||||
|
||||
# manage $XDG_CONFIG_HOME/mimeapps.list
|
||||
# xdg search all desktop entries from $XDG_DATA_DIRS, check it by command:
|
||||
# echo $XDG_DATA_DIRS
|
||||
# echo $XDG_DATA_DIRS
|
||||
# the system-level desktop entries can be list by command:
|
||||
# ls -l /run/current-system/sw/share/applications/
|
||||
# the user-level desktop entries can be list by command(user ryan):
|
||||
# ls /etc/profiles/per-user/ryan/share/applications/
|
||||
mimeApps = {
|
||||
enable = true;
|
||||
defaultApplications =
|
||||
let
|
||||
browser = [ "firefox.desktop" ];
|
||||
in
|
||||
{
|
||||
"application/json" = browser;
|
||||
"application/pdf" = browser; # TODO: pdf viewer
|
||||
defaultApplications = let
|
||||
browser = ["firefox.desktop"];
|
||||
in {
|
||||
"application/json" = browser;
|
||||
"application/pdf" = browser; # TODO: pdf viewer
|
||||
|
||||
"text/html" = browser;
|
||||
"text/xml" = browser;
|
||||
"application/xml" = browser;
|
||||
"application/xhtml+xml" = browser;
|
||||
"application/xhtml_xml" = browser;
|
||||
"application/rdf+xml" = browser;
|
||||
"application/rss+xml" = browser;
|
||||
"application/x-extension-htm" = browser;
|
||||
"application/x-extension-html" = browser;
|
||||
"application/x-extension-shtml" = browser;
|
||||
"application/x-extension-xht" = browser;
|
||||
"application/x-extension-xhtml" = browser;
|
||||
"text/html" = browser;
|
||||
"text/xml" = browser;
|
||||
"application/xml" = browser;
|
||||
"application/xhtml+xml" = browser;
|
||||
"application/xhtml_xml" = browser;
|
||||
"application/rdf+xml" = browser;
|
||||
"application/rss+xml" = browser;
|
||||
"application/x-extension-htm" = browser;
|
||||
"application/x-extension-html" = browser;
|
||||
"application/x-extension-shtml" = browser;
|
||||
"application/x-extension-xht" = browser;
|
||||
"application/x-extension-xhtml" = browser;
|
||||
|
||||
"x-scheme-handler/about" = browser;
|
||||
"x-scheme-handler/ftp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
"x-scheme-handler/https" = browser;
|
||||
"x-scheme-handler/unknown" = browser;
|
||||
"x-scheme-handler/about" = browser;
|
||||
"x-scheme-handler/ftp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
"x-scheme-handler/https" = browser;
|
||||
"x-scheme-handler/unknown" = browser;
|
||||
|
||||
"x-scheme-handler/discord" = [ "discord.desktop" ];
|
||||
"x-scheme-handler/tg" = [ "telegramdesktop.desktop" ];
|
||||
"x-scheme-handler/discord" = ["discord.desktop"];
|
||||
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
|
||||
|
||||
"audio/*" = [ "mpv.desktop" ];
|
||||
"video/*" = [ "mpv.dekstop" ];
|
||||
"image/*" = [ "imv.desktop" ];
|
||||
};
|
||||
"audio/*" = ["mpv.desktop"];
|
||||
"video/*" = ["mpv.dekstop"];
|
||||
"image/*" = ["imv.desktop"];
|
||||
};
|
||||
|
||||
associations.removed =
|
||||
let
|
||||
browser = [ "google-chrome.desktop" ];
|
||||
in
|
||||
{
|
||||
"text/html" = browser;
|
||||
"text/xml" = browser;
|
||||
"application/xml" = browser;
|
||||
"application/xhtml+xml" = browser;
|
||||
"application/xhtml_xml" = browser;
|
||||
"application/rdf+xml" = browser;
|
||||
"application/rss+xml" = browser;
|
||||
"image/gif" = browser;
|
||||
"image/jpeg" = browser;
|
||||
"image/png" = browser;
|
||||
"image/webp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
"x-scheme-handler/https" = browser;
|
||||
"application/pdf" = browser;
|
||||
};
|
||||
associations.removed = let
|
||||
browser = ["google-chrome.desktop"];
|
||||
in {
|
||||
"text/html" = browser;
|
||||
"text/xml" = browser;
|
||||
"application/xml" = browser;
|
||||
"application/xhtml+xml" = browser;
|
||||
"application/xhtml_xml" = browser;
|
||||
"application/rdf+xml" = browser;
|
||||
"application/rss+xml" = browser;
|
||||
"image/gif" = browser;
|
||||
"image/jpeg" = browser;
|
||||
"image/png" = browser;
|
||||
"image/webp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
"x-scheme-handler/https" = browser;
|
||||
"application/pdf" = browser;
|
||||
};
|
||||
};
|
||||
|
||||
userDirs = {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
{ pkgs, config, lib, ... }: {
|
||||
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
home.file.".config/fcitx5/profile".source = ./profile;
|
||||
home.file.".config/fcitx5/profile-bak".source = ./profile; # used for backup
|
||||
|
||||
# every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile file,
|
||||
# every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile file,
|
||||
# which will override my config managed by home-manager
|
||||
# so we need to remove it before everytime we rebuild the config
|
||||
home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
|
||||
home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
||||
rm -f "${config.xdg.configHome}/fcitx5/profile"
|
||||
'';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{ pkgs, ...}:
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
imports = [
|
||||
./wayland-apps.nix
|
||||
];
|
||||
@@ -22,7 +21,6 @@
|
||||
home.file.".gtkrc-2.0".source = ./gtkrc-2.0;
|
||||
home.file.".config/hypr/wallpapers/wallpaper.png".source = ../wallpapers/wallpaper.png;
|
||||
|
||||
|
||||
# music player - mpd
|
||||
home.file.".config/mpd" = {
|
||||
source = ./mpd;
|
||||
@@ -58,5 +56,4 @@
|
||||
package = pkgs.qogir-theme;
|
||||
size = 64;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
{ pkgs
|
||||
, ...
|
||||
}:
|
||||
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
|
||||
programs = {
|
||||
|
||||
# source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix
|
||||
google-chrome = {
|
||||
enable = true;
|
||||
|
||||
commandLineArgs = [
|
||||
# make it use GTK_IM_MODULE if it runs with Gtk4, so fcitx5 can work with it.
|
||||
# (only supported by chromium/chrome at this time, not electron)
|
||||
# (only supported by chromium/chrome at this time, not electron)
|
||||
"--gtk-version=4"
|
||||
# make it use text-input-v1, which works for kwin 5.27 and weston
|
||||
# "--enable-wayland-ime"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{ pkgs, ...}:
|
||||
{
|
||||
{pkgs, ...}: {
|
||||
# i3 window manager's config, based on https://github.com/endeavouros-team/endeavouros-i3wm-setup
|
||||
|
||||
imports = [
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
{ pkgs
|
||||
, ...
|
||||
}: {
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
firefox
|
||||
xsel # for clipboard support in x11, required by tmux's clipboard support
|
||||
xsel # for clipboard support in x11, required by tmux's clipboard support
|
||||
];
|
||||
|
||||
|
||||
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
|
||||
programs = {
|
||||
|
||||
# source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix
|
||||
google-chrome = {
|
||||
enable = true;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
{ username, ... }: {
|
||||
imports = [
|
||||
../base/server
|
||||
|
||||
@@ -9,12 +7,9 @@
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = let
|
||||
name = "ryan";
|
||||
in
|
||||
{
|
||||
username = name;
|
||||
homeDirectory = "/home/${name}";
|
||||
home = {
|
||||
username = username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
|
||||
Reference in New Issue
Block a user