diff --git a/sdata/dist-nix/README.md b/sdata/dist-nix/README.md index 458556d72..20f80025d 100644 --- a/sdata/dist-nix/README.md +++ b/sdata/dist-nix/README.md @@ -6,24 +6,10 @@ **NOTE: The sdata/dist-nix is not for NixOS but every distro, using Nix and home-manager.** ## plan -TODO: -Write a proper `flake.nix` and optionally `home.nix` and other files under `./sdata/dist-nix/iiqs-hm/` to install all dependencies that `./sdata/dist-arch/install-deps.sh` does. (**excluding** the screenlock) - -TODO: -In this script, implement the process below: -1. Warning user about "this script is only experimental and must only use it at your own risks.", and prompt `y/N` (default N) before proceeding. -2. If nix not installed: - 1. install nix via [NixOS/experimental-nix-installer](https://github.com/NixOS/experimental-nix-installer) - 2. Enable nix for shell - - Update: Skip this step cuz the nix-installer will handle it automatically e.g. in `/etc/zsh/zshrc`. - 3. Ensure the experimental feature, Nix Flake, is enabled. -3. cd to `iiqs-hm` and use something like `home-manager switch --flake .#iiqs` to install the dependencies. -4. Install screen lock using system package manager of the current distro. - Note that this script must be idempotent. TODO: -Write guide for people already use nix, so they can manually grab things from this repo to their own Nix/home-manager configurations to install the dependencies. +- [ ] Write a proper `flake.nix` and `home.nix` and other files under `dist-nix/home-manager/` to install all dependencies that `dist-arch/` does. (**excluding** the screenlock) ## Attentions ### PAM @@ -37,61 +23,4 @@ The problem could be solved by using the system-provided libpam instead. See also https://github.com/caelestia-dots/shell/issues/668 ### NixGL -On non-NixOS distros, packages installed via home-manager have problem accessing GPU, especially Hyprland because it requires GPU acceleration to launch. `nixGL` should be used to address the problem. Example code in `home.nix`: -``` -{ config, lib, pkgs, nixgl, ... }: -{ - nixGL.packages = nixgl.packages; - nixGL.defaultWrapper = "mesa"; - - # other lines not showed here ... - - home = { - packages = with pkgs; [ - cowsay # normal packages that does not need nixGL - lolcat - # other lines not showed here ... - ] - ++ [ - (config.lib.nixGL.wrap pkgs.firefox-bin) - (config.lib.nixGL.wrap pkgs.hyprland) - # other lines not showed here ... - ]; - # other lines not showed here ... - }; -} -``` - -And in `flake.nix`: -```nix -{ - inputs = { - nixpkgs.url = "nixpkgs/nixos-25.05"; - home-manager = { - url = "github:nix-community/home-manager/release-25.05"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - hyprland = { - url = "github:hyprwm/Hyprland"; - }; - nixgl.url = "github:nix-community/nixGL"; - }; - outputs = { nixpkgs, home-manager, nixgl, ... }: - let - lib = nixpkgs.lib; - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - overlays = [ nixgl.overlay ]; - }; - in { - homeConfigurations = { - mydot = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { inherit nixgl; }; - modules = [ ./home.nix ]; - }; - }; - }; -} -``` +On non-NixOS distros, packages installed via home-manager have problem accessing GPU, especially Hyprland because it requires GPU acceleration to launch. `nixGL` should be used to address the problem. diff --git a/sdata/dist-nix/home-manager/flake.nix b/sdata/dist-nix/home-manager/flake.nix new file mode 100644 index 000000000..3422f5c4b --- /dev/null +++ b/sdata/dist-nix/home-manager/flake.nix @@ -0,0 +1,41 @@ +# flake.nix +{ + description = "illogical-impulse"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-25.05"; + + home-manager = { + url = "github:nix-community/home-manager/release-25.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + hyprland = { + url = "github:hyprwm/Hyprland"; + }; + nixgl.url = "github:nix-community/nixGL"; + }; + + outputs = { nixpkgs, home-manager, nixgl, ... }: + let + home_attrs = rec { + username = import ./username.nix; + homeDirectory = "/home/${username}"; + stateVersion = "25.05"; + }; + system = "x86_64-linux"; + lib = nixpkgs.lib; + pkgs = import nixpkgs { + inherit system; + }; + in { + homeConfigurations = { + illogical_impulse = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { inherit nixgl home_attrs; }; + modules = [ + ./home.nix + ]; + }; + }; + }; +} diff --git a/sdata/dist-nix/home-manager/home.nix b/sdata/dist-nix/home-manager/home.nix new file mode 100644 index 000000000..6f17bd4f0 --- /dev/null +++ b/sdata/dist-nix/home-manager/home.nix @@ -0,0 +1,57 @@ +{ config, lib, pkgs, nixgl, home_attrs, ... }: +{ + programs.home-manager.enable = true; + nixGL.packages = nixgl.packages; + nixGL.defaultWrapper = "mesa"; + + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-gnome + xdg-desktop-portal-gtk + xdg-desktop-portal-wlr + ]; + config.hyprland = { + default = [ "hyprland" "gtk" ]; + "org.freedesktop.impl.portal.ScreenCast" = [ + "gnome" + ]; + }; + }; + ## Allow fontconfig to discover fonts in home.packages + fonts.fontconfig.enable = true; + + # home.sessionVariables.NIXOS_OZONE_WL = "1"; + wayland.windowManager.hyprland = { + ## Make sure home-manager not generate ~/.config/hypr/hyprland.conf + systemd.enable = false; plugins = []; settings = {}; extraConfig = ""; + enable = true; + ## Use NixGL + package = config.lib.nixGL.wrap pkgs.hyprland; + }; + + home = { + packages = with pkgs; [ + ##### Sure ##### + ## Basic cli tool + ## inetutils: provides hostname, ifconfig, ping, etc. + ## libnotify: provides notify-send + jq rsync inetutils libnotify + ## Media related + brightnessctl playerctl pavucontrol + ## Clipboard/Emoji + wl-clipboard cliphist + ## Terminal and shell + foot cowsay lolcat + + ##### Fonts/Icons/Cursors/Decoration ##### + fontconfig + + ##### Other basic things ##### + dbus xorg.xlsclients networkmanager + + ##### Not work, to be solved ##### + # swaylock pamtester + ]; + }//home_attrs; +} diff --git a/sdata/dist-nix/home-manager/username.nix b/sdata/dist-nix/home-manager/username.nix new file mode 100644 index 000000000..e16c76dff --- /dev/null +++ b/sdata/dist-nix/home-manager/username.nix @@ -0,0 +1 @@ +"" diff --git a/sdata/dist-nix/install-deps.sh b/sdata/dist-nix/install-deps.sh index 59ffec887..6b11606c2 100644 --- a/sdata/dist-nix/install-deps.sh +++ b/sdata/dist-nix/install-deps.sh @@ -1,8 +1,6 @@ # This script is meant to be sourced. # It's not for directly running. -# This file is currently WIP. - function install_home-manager(){ # https://nix-community.github.io/home-manager/index.xhtml#sec-install-standalone local cmd=home-manager @@ -128,4 +126,4 @@ if ! command -v home-manager >/dev/null 2>&1;then fi showfun hm_deps -v hm_deps \ No newline at end of file +v hm_deps