From 377cb5504af2c1b6eade7f158a54b9c1a2e723e1 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Thu, 22 Feb 2024 14:19:34 +0000 Subject: [PATCH] Setup FG42 as the window manager for my user --- flake.lock | 65 +++++---- flake.nix | 24 ++-- modules/default.nix | 13 +- users/lxsameer/desktop.nix | 261 +++++++++++++++++++++++++++++++++++++ users/lxsameer/fg42.el | 109 ++++++++++++++++ worlds/majin.nix | 16 ++- 6 files changed, 444 insertions(+), 44 deletions(-) create mode 100644 users/lxsameer/desktop.nix create mode 100644 users/lxsameer/fg42.el diff --git a/flake.lock b/flake.lock index 580d51b..a6b7306 100644 --- a/flake.lock +++ b/flake.lock @@ -25,23 +25,19 @@ "inputs": { "emacs-overlay": "emacs-overlay", "flake-utils": "flake-utils_2", - "nixpkgs": [ - "nixpkgs" - ] + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1708440830, - "narHash": "sha256-lIOOt64A/NiRWn5vrRX8CCklugzdbgc48ju7YIJ1Gyg=", - "ref": "v4", - "rev": "82b377f00e1d8802233d79202bb29e4f33c538ac", - "revCount": 1039, + "dirtyRev": "d2713dab3907cacba21bde64d68289bbb6fb495f-dirty", + "dirtyShortRev": "d2713da-dirty", + "lastModified": 1708530364, + "narHash": "sha256-os+zgz16WsM8kLirJ+SX4+sUqHArmdmZi5u3tG+ksK8=", "type": "git", - "url": "ssh://git@git.devheroes.codes/FG42/FG42.git" + "url": "file:///home/lxsameer/.fg42" }, "original": { - "ref": "v4", "type": "git", - "url": "ssh://git@git.devheroes.codes/FG42/FG42.git" + "url": "file:///home/lxsameer/.fg42" } }, "flake-utils": { @@ -105,16 +101,17 @@ ] }, "locked": { - "lastModified": 1708294481, - "narHash": "sha256-DZtxmeb4OR7iCaKUUuq05ADV2rX8WReZEF7Tq//W0+Y=", + "lastModified": 1708451036, + "narHash": "sha256-tgZ38NummEdnXvxj4D0StHBzXgceAw8CptytHljH790=", "owner": "nix-community", "repo": "home-manager", - "rev": "a54e05bc12d88ff2df941d0dc1183cb5235fa438", + "rev": "517601b37c6d495274454f63c5a483c8e3ca6be1", "type": "github" }, "original": { "owner": "nix-community", "repo": "home-manager", + "rev": "517601b37c6d495274454f63c5a483c8e3ca6be1", "type": "github" } }, @@ -141,11 +138,11 @@ ] }, "locked": { - "lastModified": 1708402276, - "narHash": "sha256-7ZTUHdMwy8o6d8ela6H7H3UcS7cyns4D1zuWbmU1dCI=", + "lastModified": 1708563055, + "narHash": "sha256-FaojUZNu+YPFi3eCI7mL4kxPKQ51DoySa7mqmllUOuc=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "fa146e1a156c83b009b398213c661d6b46d71421", + "rev": "f4631dee1a0fd56c0db89860e83e3588a28c7631", "type": "github" }, "original": { @@ -156,11 +153,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1708091350, - "narHash": "sha256-o28BJYi68qqvHipT7V2jkWxDiMS1LF9nxUsou+eFUPQ=", + "lastModified": 1708594753, + "narHash": "sha256-c/gH7iXS/IYH9NrFOT+aJqTq+iEBkvAkpWuUHGU3+f0=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "106d3fec43bcea19cb2e061ca02531d54b542ce3", + "rev": "3f7d0bca003eac1a1a7f4659bbab9c8f8c2a0958", "type": "github" }, "original": { @@ -221,18 +218,34 @@ "locked": { "lastModified": 1707451808, "narHash": "sha256-UwDBUNHNRsYKFJzyTMVMTF5qS4xeJlWoeyJf+6vvamU=", - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "442d407992384ed9c0e6d352de75b69079904e4e", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "442d407992384ed9c0e6d352de75b69079904e4e", "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1708564076, + "narHash": "sha256-KKkqoxlgx9n3nwST7O2kM8tliDOijiSSNaWuSkiozdQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "98b00b6947a9214381112bdb6f89c25498db4959", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "fg42": "fg42", @@ -240,7 +253,7 @@ "home-manager": "home-manager", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "sops-nix": "sops-nix" } }, @@ -252,11 +265,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1708447565, - "narHash": "sha256-N2oVVguBU2ueGRoYEynedunF+xOKv6X3ZS43YnB9pbg=", + "lastModified": 1708500294, + "narHash": "sha256-mvJIecY3tDKZh7297mqOtOuAvP7U1rqjfLNfmfkjFpU=", "owner": "Mic92", "repo": "sops-nix", - "rev": "f88661c9a9f4ff10b6a5aca18d5caf7d537e3923", + "rev": "f6b80ab6cd25e57f297fe466ad689d8a77057c11", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c76107d..3401af8 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ description = "lxsameer's universe"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; #442d407992384ed9c0e6d352de75b69079904e4e sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -30,16 +30,17 @@ }; home-manager = { - url = "github:nix-community/home-manager"; + url = "github:nix-community/home-manager/517601b37c6d495274454f63c5a483c8e3ca6be1"; inputs.nixpkgs.follows = "nixpkgs"; }; - fg42 = { - type = "git"; - url = "git@git.devheroes.codes:FG42/FG42.git"; - ref = "v4"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # fg42 = { + # type = "git"; + # url = "git@git.devheroes.codes:FG42/FG42.git"; + # ref = "v4"; + # }; + + fg42.url = "/home/lxsameer/.fg42"; flake_utils.url = "github:numtide/flake-utils"; @@ -57,7 +58,10 @@ pkgs = import nixpkgs { inherit system; }; utils = pkgs.callPackage ./utils {}; - modules = pkgs.callPackage ./modules { inherit (inputs) nixos-generators; }; + modules = pkgs.callPackage ./modules { + inherit system pkgs; + inherit (inputs) nixos-generators; + }; nativeBuildInputs = with pkgs; [ qemu @@ -79,7 +83,7 @@ nixosConfigurations = { majin = import ./worlds/majin.nix { - inherit nixpkgs inputs system; + inherit nixpkgs inputs system pkgs; mods = modules; }; }; diff --git a/modules/default.nix b/modules/default.nix index 770515a..87d8292 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -36,6 +36,7 @@ rec { # Neverever change this value system.stateVersion = "23.11"; + services.getty.greetingLine = ''<<< Welcome to Universe ${config.system.nixos.label} (\m) - \l >>>''; # Include some utilities that are useful for installing or repairing # the system. environment.systemPackages = [ @@ -74,6 +75,8 @@ rec { pkgs.curl pkgs.htop + + pkgs.emacs ]; environment.variables.EDITOR = "emacs"; @@ -95,15 +98,11 @@ rec { desktop = { pkgs, lib, inputs, ... }: { environment.noXlibs = lib.mkForce false; + + services.xserver = { enable = true; displayManager = { - gdm = { - - enable = true; - wayland = false; - banner = "test tset tshnetht"; - }; startx = { enable = true; }; @@ -128,7 +127,7 @@ rec { environment.systemPackages = [ pkgs.glxinfo - inputs.fg42 + #inputs.fg42.packages.${params.system}.default ]; }; diff --git a/users/lxsameer/desktop.nix b/users/lxsameer/desktop.nix new file mode 100644 index 0000000..fe628e2 --- /dev/null +++ b/users/lxsameer/desktop.nix @@ -0,0 +1,261 @@ +# Universe - The big bang to my universe +# +# Copyright (c) 2023-2024 Sameer Rahmani +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +{ config, pkgs, ... }@params: +{ + + home.username = "lxsameer"; + home.homeDirectory = "/home/lxsameer"; + + # link the configuration file in current directory to the specified location in home directory + # home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg; + + # link all files in `./scripts` to `~/.config/i3/scripts` + # home.file.".config/i3/scripts" = { + # source = ./scripts; + # recursive = true; # link recursively + # executable = true; # make all files executable + # }; + + # encode the file content in nix configuration file directly + # home.file.".xxx".text = '' + # xxx + # ''; + + home.file.".xinitrc".text = '' + # xset b off + # xsetroot -solid black & + exec ${params.fg42}/bin/fg42-wm + ''; + home.file.".fg42.el".source = ./fg42.el; + + # set cursor size and dpi for 4k monitor + xresources.properties = { + "Xcursor.size" = 16; + "Xft.dpi" = 172; + }; + + fonts.fontconfig.enable = true; + + # Packages that should be installed to the user profile. + home.packages = with pkgs; [ + params.fg42 + # archives + zip + xz + unzip + + # utils + ripgrep + eza # A modern replacement for ‘ls’ + fzf # A command-line fuzzy finder + + # networking tools + mtr # A network diagnostic tool + iperf3 # A TCP, UDP, and SCTP network bandwidth measurement tool + dnsutils # `dig` + `nslookup` + ldns # replacement of `dig`, it provide the command `drill` + aria2 # A lightweight multi-protocol & multi-source command-line download utility + socat # replacement of openbsd-netcat + nmap # A utility for network discovery and security auditing + + # misc + file + which + tree + gnused + gnutar + gawk + zstd + gnupg + + # nix related + # + # it provides the command `nom` works just like `nix` + # with more details log output + nix-output-monitor + nix-tree + nix-index + + # productivity + btop # replacement of htop/nmon + iotop # io monitoring + iftop # network monitoring + + # system call monitoring + strace # system call monitoring + ltrace # library call monitoring + lsof # list open files + + # system tools + sysstat + lm_sensors # for `sensors` command + ethtool + pciutils + usbutils + + vazir-fonts + fira-code + nerdfonts + ]; + + # basic configuration of git, please change to your own + programs.git = { + enable = true; + userName = "Sameer Rahmani"; + userEmail = "lxsameer@gnu.org"; + }; + + # starship - an customizable prompt for any shell + programs.starship = { + enable = true; + # custom settings + settings = { + add_newline = true; + aws.disabled = true; + gcloud.disabled = true; + line_break.disabled = true; + }; + }; + + # alacritty - a cross-platform, GPU-accelerated terminal emulator + programs.alacritty = { + enable = true; + # custom settings + settings = { + env.TERM = "xterm-256color"; + font = { + size = 12; + draw_bold_text_with_bright_colors = true; + }; + scrolling.multiplier = 5; + selection.save_to_clipboard = true; + }; + }; + + programs.zsh = { + enable = true; + autocd = true; + # dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableCompletion = true; + shellAliases = { + sl = "exa"; + ls = "exa"; + l = "exa -l"; + la = "exa -la"; + ip = "ip --color=auto"; + g = "git"; + d = "docker"; + n = "nix"; + _ = "sudo"; + }; + + initExtra = '' + bindkey '^ ' autosuggest-accept + AGKOZAK_CMD_EXEC_TIME=5 + AGKOZAK_COLORS_CMD_EXEC_TIME='yellow' + AGKOZAK_COLORS_PROMPT_CHAR='magenta' + AGKOZAK_CUSTOM_SYMBOLS=( '⇣⇡' '⇣' '⇡' '+' 'x' '!' '>' '?' ) + AGKOZAK_MULTILINE=0 + AGKOZAK_PROMPT_CHAR=( ❯ ❯ ❮ ) + eval $(thefuck --alias) + autopair-init + ''; + + plugins = with pkgs; [ + { + name = "agkozak-zsh-prompt"; + src = fetchFromGitHub { + owner = "agkozak"; + repo = "agkozak-zsh-prompt"; + rev = "v3.7.0"; + sha256 = "1iz4l8777i52gfynzpf6yybrmics8g4i3f1xs3rqsr40bb89igrs"; + }; + file = "agkozak-zsh-prompt.plugin.zsh"; + } + { + name = "formarks"; + src = fetchFromGitHub { + owner = "wfxr"; + repo = "formarks"; + rev = "8abce138218a8e6acd3c8ad2dd52550198625944"; + sha256 = "1wr4ypv2b6a2w9qsia29mb36xf98zjzhp3bq4ix6r3cmra3xij90"; + }; + file = "formarks.plugin.zsh"; + } + { + name = "zsh-syntax-highlighting"; + src = fetchFromGitHub { + owner = "zsh-users"; + repo = "zsh-syntax-highlighting"; + rev = "0.6.0"; + sha256 = "0zmq66dzasmr5pwribyh4kbkk23jxbpdw4rjxx0i7dx8jjp2lzl4"; + }; + file = "zsh-syntax-highlighting.zsh"; + } + { + name = "zsh-abbrev-alias"; + src = fetchFromGitHub { + owner = "momo-lab"; + repo = "zsh-abbrev-alias"; + rev = "637f0b2dda6d392bf710190ee472a48a20766c07"; + sha256 = "16saanmwpp634yc8jfdxig0ivm1gvcgpif937gbdxf0csc6vh47k"; + }; + file = "abbrev-alias.plugin.zsh"; + } + { + name = "zsh-autopair"; + src = fetchFromGitHub { + owner = "hlissner"; + repo = "zsh-autopair"; + rev = "34a8bca0c18fcf3ab1561caef9790abffc1d3d49"; + sha256 = "1h0vm2dgrmb8i2pvsgis3lshc5b0ad846836m62y8h3rdb3zmpy1"; + }; + file = "autopair.zsh"; + } + ]; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + # This value determines the home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new home Manager release introduces backwards + # incompatible changes. + # + # You can update home Manager without changing this value. See + # the home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "23.11"; + + # Let home Manager install and manage itself. + programs.home-manager.enable = true; + + xsession.enable = true; + xsession.scriptPath = ".fg42-xsession"; + xsession.windowManager.command = "${params.fg42}/bin/fg42-wm"; + + # services.xserver = { + # enable = true; + # autorun = false; + # displayManager.startx.enable = true; + # }; + + +} diff --git a/users/lxsameer/fg42.el b/users/lxsameer/fg42.el new file mode 100644 index 0000000..7272f5d --- /dev/null +++ b/users/lxsameer/fg42.el @@ -0,0 +1,109 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2020 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: + +;; Uncomment this line for debugging +;; (setq debug-on-error t) + +(defvar global-font-size 11) + +(use-flags + (fg42/merge-with-default-flags + -wm + dracula-theme + -badwolf-theme + python + golang + -vterm + -smart-mode-line + -mini-mode-line + disable-modeline + fg42/region-expansion-cube)) + + +;;TODO: Move this block to a macro or something =========== +(when-wm + (setq global-font-size 8) + (custom-set-faces + '(mini-modeline-mode-line + ((((background light)) + :background "#aa0000" :height 0.1 :box nil) + (t + :background "#6272a4" :height 0.1 :box nil)))) + (fg42/wm-cube :number-of-workspaces 9) + + ;; Change the resolution and monitors to your need + (defvar monitors + '(:hdmi-only + ("--output HDMI-A-0 --primary"))) + + (require 'seq) + (defun monitor-profiles () + (mapcar + #'car + (seq-partition monitors 2))) + + (defun monitor (mon) + (interactive + (list (completing-read + "Monitor Profole: " + (monitor-profiles)))) + + (let ((cmd (mapconcat (lambda (x) (format "xrandr %s" x)) + (plist-get monitors (intern (format "%s" mon))) + " && "))) + (message "Setting monitor profile: %s" cmd) + (async-shell-command cmd "*xrandr*"))) + + (comment + ;; how to run it via elisp + (monitor :hdmi-only)) + + (use-flags + (fg42/merge-with-default-flags + wm + -python + -golang + rcirc + vterm + -company + -projectile + -lsp + -flycheck + fg42/region-expansion-cube))) + +(fg42/editor + :fg42/cursor-cube '(:type 'bar :color "#bd93f9") + :fg42/font-cube '(:font-name "Fira code" :font-size global-font-size) + :fg42/org-cube '(:global-tags '(("Math", ?m) + ("Serene", ?s) + ("FG42", ?f) + ("Physics", ?p) + ("Lab", ?l) + ("Life", ?L)))) + +(when (file-exists-p "~/.fg42.user.el") + (load "~/.fg42.user.el")) + +(provide '.fg42) +;;; .fg42.el ends here diff --git a/worlds/majin.nix b/worlds/majin.nix index 8d94e23..0675aa2 100644 --- a/worlds/majin.nix +++ b/worlds/majin.nix @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -{ nixpkgs, mods, system, inputs }: +{ nixpkgs, mods, system, inputs, ... }: let this = { pkgs, config, lib, ... }: { time.timeZone = lib.mkDefault "Europe/Dublin"; @@ -25,6 +25,11 @@ let ]; }; + + lxsameer.desktop = import ../users/lxsameer/desktop.nix; + + fg42 = inputs.fg42.packages.${system}.default; + in nixpkgs.lib.nixosSystem { inherit system; @@ -37,6 +42,15 @@ in nixpkgs.lib.nixosSystem { desktop generator inputs.home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.users.lxsameer = lxsameer.desktop; + home-manager.extraSpecialArgs = { + inherit inputs fg42; + }; + } ]); specialArgs = { inherit inputs; };