massive rewrite using flake-parts

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-08 01:00:12 +05:30
parent dfd8c57b60
commit aaf19ee844
45 changed files with 245 additions and 531 deletions

16
home/default.nix Normal file
View File

@@ -0,0 +1,16 @@
{ self, inputs, ... }:
{
flake.homeConfigurations = {
natto = inputs.home-manager.lib.homeManagerConfiguration {
modules = [
./natto
./modules/secret.nix
];
pkgs = self.legacyPackages.x86_64-linux;
extraSpecialArgs = {
inherit inputs;
flake = self;
};
};
};
}

View File

@@ -1,166 +0,0 @@
#modified version of home-manager emacs service module for personal use
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.baremacs;
emacsCfg = config.programs.emacs;
emacsBinPath = "${cfg.package}/bin";
# Match the default socket path for the Emacs version so emacsclient continues
# to work without wrapping it.
socketDir = "%t/emacs";
socketPath = "${socketDir}/server";
in
{
options.services.baremacs = {
enable = mkEnableOption "the Emacs daemon";
package = mkOption {
type = types.package;
default = pkgs.emacs;
defaultText = literalExpression ''
pkgs.emacs
'';
description = "The Emacs package to use.";
};
socketActivation = {
enable = mkEnableOption "systemd socket activation for the Emacs service";
};
defaultEditor = {
enable = mkOption rec {
type = types.bool;
default = false;
example = !default;
description = "Whether to change the EDITOR environment variable or not";
};
editor = mkOption rec {
type = types.enum [ "emacs" "emacsclient" ];
default = null;
example = "emacsclient";
description = "Whether to change the EDITOR environment variable or not";
};
};
copyConfigFiles = {
enable = mkOption rec {
type = types.bool;
default = false;
example = !default;
description = "Whether to copy the config files to ~/.emacs.d or not";
};
files = mkOption rec {
type = types.attrsOf types.path;
default = { };
example = { "init.el" = ./init.el; };
description = "What files to copy under what name";
};
};
};
config = mkIf cfg.enable (mkMerge [
{
assertions = [
(lib.hm.assertions.assertPlatform "services.emacs" pkgs
lib.platforms.linux)
{
assertion = cfg.defaultEditor.enable -> cfg.defaultEditor.editor != null;
message = ''
services.baremacs.defaultEditor.enable requires services.baremacs.defaultEditor.editor to be set
'';
}
];
systemd.user.services.emacs = {
Unit = {
Description = "Emacs text editor";
Documentation =
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
# Avoid killing the Emacs session, which may be full of
# unsaved buffers.
X-RestartIfChanged = false;
} // optionalAttrs (cfg.socketActivation.enable) {
# Emacs deletes its socket when shutting down, which systemd doesn't
# handle, resulting in a server without a socket.
# See https://github.com/nix-community/home-manager/issues/2018
RefuseManualStart = true;
};
Service = {
Type = "notify";
# We wrap ExecStart in a login shell so Emacs starts with the user's
# environment, most importantly $PATH and $NIX_PROFILES. It may be
# worth investigating a more targeted approach for user services to
# iport the user environment.
ExecStart = ''
${pkgs.runtimeShell} -l -c "${emacsBinPath}/emacs --fg-daemon${
# In case the user sets 'server-directory' or 'server-name' in
# their Emacs config, we want to specify the socket path explicitly
# so launching 'emacs.service' manually doesn't break emacsclient
# when using socket activation.
optionalString cfg.socketActivation.enable
"=${escapeShellArg socketPath}"
}"'';
# Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services.
SuccessExitStatus = 15;
Restart = "on-failure";
} // optionalAttrs (cfg.socketActivation.enable) {
# Use read-only directory permissions to prevent emacs from
# deleting systemd's socket file before exiting.
ExecStartPost =
"${pkgs.coreutils}/bin/chmod --changes -w ${socketDir}";
ExecStopPost =
"${pkgs.coreutils}/bin/chmod --changes +w ${socketDir}";
};
} // optionalAttrs (!cfg.socketActivation.enable) {
Install = { WantedBy = [ "default.target" ]; };
};
home = {
sessionVariables = mkIf cfg.defaultEditor.enable {
EDITOR = let editor = cfg.defaultEditor.editor; in
getBin (pkgs.writeShellScript "editor" ''
exec ${
getBin cfg.package
}/bin/'' + editor + head (optional (editor == "emacsclient") '' "''${@:---create-frame}"''));
};
packages = [ cfg.package ];
file = mkIf cfg.copyConfigFiles.enable
(mapAttrs'
(n: v:
attrsets.nameValuePair (".emacs.d/" + n) { source = v; })
cfg.copyConfigFiles.files);
};
}
(mkIf cfg.socketActivation.enable {
systemd.user.sockets.emacs = {
Unit = {
Description = "Emacs text editor";
Documentation =
"info:emacs man:emacs(1) https://gnu.org/software/emacs/";
};
Socket = {
ListenStream = socketPath;
FileDescriptorName = "server";
SocketMode = "0600";
DirectoryMode = "0700";
};
Install = { WantedBy = [ "sockets.target" ]; };
};
})
]);
}

View File

@@ -1,5 +1,11 @@
{ config, pkgs, lib, ... }:
{
home = {
homeDirectory = "/home/natto";
username = "natto";
stateVersion = "22.11";
};
imports = [
./email.nix
./secrets

View File

@@ -0,0 +1,19 @@
--- a/gruvbox.el 2021-05-17 21:19:07.731014155 +0530
+++ b/gruvbox.el 2021-05-17 21:20:11.297990471 +0530
@@ -162,11 +162,11 @@
;; line numbers
- (line-number (:foreground gruvbox-dark4 :background gruvbox-dark1))
- (line-number-current-line (:foreground gruvbox-bright_orange :background gruvbox-dark2))
- (linum (:foreground gruvbox-dark4 :background gruvbox-dark1))
- (linum-highlight-face (:foreground gruvbox-bright_orange :background gruvbox-dark2))
- (linum-relative-current-face (:foreground gruvbox-bright_orange :background gruvbox-dark2))
+ (line-number (:foreground gruvbox-dark4 :background nil))
+ (line-number-current-line (:foreground gruvbox-bright_orange :background gruvbox-dark1))
+ (linum (:foreground gruvbox-dark4 :background nil))
+ (linum-highlight-face (:foreground gruvbox-bright_orange :background gruvbox-dark1))
+ (linum-relative-current-face (:foreground gruvbox-bright_orange :background gruvbox-dark1))
;; Highlight indentation mode
(highlight-indentation-current-column-face (:background gruvbox-dark2))

View File

@@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, flake, inputs, pkgs, ... }:
{
home.packages = with pkgs; [
@@ -36,8 +36,8 @@
jmtpfs
neofetch
xdotool
nbfc-linux
customscripts
(inputs.nbfc.packages.${pkgs.system}.nbfc-client-c)
(flake.packages.${pkgs.system}.customscripts)
# GUI utils
(xfce.thunar.override {
@@ -50,7 +50,7 @@
xfce.xfconf
xfce.tumbler
flameshot
(master.discord.override {
(discord.override {
nss = nss_latest;
})
qbittorrent
@@ -69,12 +69,12 @@
# Wine and games and stuff
wineWowPackages.stable
master.winetricks
tlauncher
winetricks
citra
yuzu
ryujinx
gaming.osu-stable
(inputs.nix-gaming.packages.${pkgs.system}.osu-stable)
(flake.packages.${pkgs.system}.tlauncher)
# Dev shit
rust-analyzer

View File

@@ -1,6 +1,7 @@
{ pkgs, config, ... }:
{
programs = {
home-manager.enable = true;
firefox = {
enable = true;
profiles.natto = {

View File

@@ -1,26 +1,35 @@
{ config, pkgs, ... }:
let
home = config.home.homeDirectory;
in
{ config, pkgs, inputs, ... }:
{
services = {
baremacs = {
enable = true;
package = pkgs.mymacs.override {
config = ./config/emacs/config.org;
};
defaultEditor = {
enable = false;
editor = "emacsclient";
};
copyConfigFiles = {
enable = true;
files = {
"config.org" = ./config/emacs/config.org;
"init.el" = ./config/emacs/init.el;
};
};
home.file = with config; {
"config.org" = {
source = ./config/emacs/config.org;
target = "${home.homeDirectory}/.emacs.d/config.org";
};
"init.el" = {
source = ./config/emacs/init.el;
target = "${home.homeDirectory}/.emacs.d/init.el";
};
};
services = {
emacs =
let
mymacs = config: # with inputs.emacs-overlay.packages.${pkgs.system}; already resolved with overlay
with pkgs; emacsWithPackagesFromUsePackage {
inherit config;
package = emacsGit;
alwaysEnsure = true;
alwaysTangle = true;
extraEmacsPackages = epkgs: with epkgs; [
use-package
(epkgs.tree-sitter-langs.withPlugins (_: epkgs.tree-sitter-langs.plugins))
];
};
in
{
enable = true;
package = mymacs ./config/emacs/config.org;
};
sxhkd = {
enable = false;
@@ -80,7 +89,7 @@ in
background = "#dc322f";
foreground = "#eee8d5";
timeout = 0;
};
};
};
};

View File

@@ -1,7 +1,7 @@
{ pkgs, config, ... }:
{ pkgs, config, flake, ... }:
{
home.pointerCursor = {
package = pkgs.simp1e-cursors;
package = flake.packages.${pkgs.system}.simp1e-cursors;
name = "Simp1e-Solarized-Light";
x11 = {
enable = true;