diff --git a/common/default.nix b/common/default.nix new file mode 100644 index 0000000..3ebdfb2 --- /dev/null +++ b/common/default.nix @@ -0,0 +1,23 @@ +{ + inputs, + config, + lib, + ... +}: { + imports = + [ + (lib.mkAliasOptionModule ["hm"] [ + "home-manager" + "users" + config.my.user + ]) + ] + ++ lib.my.getModules [./.]; + + hm.imports = [./home.nix]; + + home-manager.extraSpecialArgs = { + inherit inputs; + }; + home-manager.useGlobalPkgs = true; +} diff --git a/common/home.nix b/common/home.nix new file mode 100644 index 0000000..d6ff25e --- /dev/null +++ b/common/home.nix @@ -0,0 +1,25 @@ +{ + inputs, + lib, + pkgs, + ... +}: { + imports = lib.my.getHmModules [./.]; + + # my = { + # difftastic.enable = true; + # direnv.enable = true; + # # helix.enable = true; + # git.enable = true; + # # gitui.enable = true; + # neovim.enable = true; + # yazi.enable = true; + # zsh.enable = true; + # }; + + # let standalone home-manager and home-manager in nixos/nix-darwin use the same derivation + home.packages = [ + (pkgs.callPackage (inputs.home-manager + /home-manager) {path = inputs.home-manager;}) + ]; + # home.stateVersion = "23.11"; +} diff --git a/common/my/default.nix b/common/my/default.nix new file mode 100644 index 0000000..0792ec4 --- /dev/null +++ b/common/my/default.nix @@ -0,0 +1,26 @@ +{lib, ...}: let + inherit (lib) mkOption types; +in { + options.my = { + user = mkOption {type = types.str;}; + name = mkOption {type = types.str;}; + email = mkOption {type = types.str;}; + uid = mkOption {type = types.int;}; + keys = mkOption {type = types.listOf types.singleLineStr;}; + }; + + config = { + my = { + user = "michael"; + name = "Michael Thomas"; + email = "michaelhthomas@outlook.com"; + uid = 1000; + keys = [ + # Neptune + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDUYHiTel+RDzygCeNwV25cnBBNioM19EQWqxPC+xq7lNlNcAQ4wi9JIOONVGkshxPXzKZyR3F53Igs9JZr1E9088L52eUp35JhW1pthai82cw1jGkj9wxcKJnU6b7QNDKA+ejPTC/ciFFKytMyPgID0ICzBRQsnj15i4lGvGDgfTQ7qfI2J855H7S7qOpY7cbsGfeoz3f8Ye1FspJFDsNu9QhX05iunBcbni0uLoTtgS5cEBRr7H9RkKR7GCfd4Ae/sp+aeDkLU4aBkEi+A8VLfR74Juia1j/3mAAmkgJKGcBCKUv0ixBGd6XclZmkF8f2Hx0z8mDxJ7U8lsDUSKdvxK7fecsM4F/GTvjrUxV1nLD4SRQ06GtBmGQGDzIn3Nm1URd6gGT9W3486XJsqmGzjuHa5o4WhmBgh/Gs8xUcv7kWD5enrYacBr+HKVJWnnLFp+XfAYaMCT6j/4jc4D9/9hijRbhboICTDxWCWtFgz7QpsO6BQpi/wkR4Ql61vPc= michael@neptune" + # Oracle + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPc/HYsbpVsyoU2n0EiqQ4+3aSiFPtddjPCGK187W24f michael@oracle" + ]; + }; + }; +} diff --git a/common/my/home.nix b/common/my/home.nix new file mode 120000 index 0000000..73537e4 --- /dev/null +++ b/common/my/home.nix @@ -0,0 +1 @@ +default.nix \ No newline at end of file diff --git a/common/system/default.nix b/common/system/default.nix new file mode 100644 index 0000000..12bec4c --- /dev/null +++ b/common/system/default.nix @@ -0,0 +1,27 @@ +{ + config, + pkgs, + ... +}: { + nix.gc = { + automatic = true; + options = "--delete-older-than 30d"; + }; + nix.optimise.automatic = true; + nix.settings = { + extra-experimental-features = [ + "flakes" + "nix-command" + ]; + keep-outputs = true; + log-lines = 25; + tarball-ttl = 43200; + trusted-users = [ + "root" + config.my.user + ]; + }; + nix.package = pkgs.nix; + programs.zsh.enable = true; + time.timeZone = "America/New_York"; +} diff --git a/darwin/default.nix b/darwin/default.nix new file mode 100644 index 0000000..24bb569 --- /dev/null +++ b/darwin/default.nix @@ -0,0 +1,18 @@ +{ + inputs, + inputs', + lib, + ... +}: { + imports = + [ + inputs.agenix.darwinModules.default + inputs.home-manager.darwinModules.home-manager + ../common + ] + ++ lib.my.getModules [./.]; + + hm.imports = [./home.nix]; + + environment.systemPackages = [inputs'.agenix.packages.default]; +} diff --git a/darwin/home.nix b/darwin/home.nix new file mode 100644 index 0000000..13ba55e --- /dev/null +++ b/darwin/home.nix @@ -0,0 +1,3 @@ +{lib, ...}: { + imports = lib.my.getHmModules [./.]; +} diff --git a/flake.lock b/flake.lock index c7c5b6b..052e768 100644 --- a/flake.lock +++ b/flake.lock @@ -153,6 +153,24 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nixvim", @@ -540,6 +558,18 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1719876945, + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1719075281, @@ -603,11 +633,27 @@ "type": "github" } }, + "nixpkgs_6": { + "locked": { + "lastModified": 1719690277, + "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixvim": { "inputs": { "devshell": "devshell", "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "git-hooks": "git-hooks", "home-manager": "home-manager_3", "nix-darwin": "nix-darwin", @@ -651,6 +697,7 @@ "agenix": "agenix", "ags": "ags", "darwin": "darwin_2", + "flake-parts": "flake-parts", "home-manager": "home-manager_2", "hyprland": "hyprland", "nix-vscode-extensions": "nix-vscode-extensions", @@ -658,6 +705,7 @@ "nixvim": "nixvim", "nur": "nur", "rust-overlay": "rust-overlay", + "treefmt-nix": "treefmt-nix_2", "unstable": "unstable", "utils": "utils" } @@ -776,6 +824,24 @@ "type": "github" } }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1719887753, + "narHash": "sha256-p0B2r98UtZzRDM5miGRafL4h7TwGRC4DII+XXHDHqek=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "bdb6355009562d8f9313d9460c0d3860f525bc6c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "unstable": { "locked": { "lastModified": 1719254875, diff --git a/flake.nix b/flake.nix index e53b77b..3e2cb28 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,8 @@ }; utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; nixvim = { url = "github:nix-community/nixvim/nixos-24.05"; inputs.nixpkgs.follows = "nixpkgs"; @@ -32,197 +34,17 @@ }; }; - outputs = { - self, - nixpkgs, - unstable, - nur, - agenix, - utils, - rust-overlay, - nix-vscode-extensions, - darwin, - home-manager, - ... - } @ inputs: let - forAllSystems = nixpkgs.lib.genAttrs utils.lib.defaultSystems; + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} { + flake = { + overlays = import ./overlays {inherit inputs;}; + }; - defaultModules = [ - self.overlaysModule - home-manager.nixosModules.home-manager - ./modules - ]; - - baseHomeModule = { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = {inherit inputs;}; + systems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-linux" + ]; + imports = [./flakes]; }; - in { - # Your custom packages - # Accessible through 'nix build', 'nix shell', etc - packages = forAllSystems (system: - import ./pkgs { - pkgs = nixpkgs.legacyPackages.${system}; - inherit inputs; - }); - - overlays = import ./overlays {inherit inputs;}; - - overlaysModule = { - nixpkgs.overlays = builtins.attrValues self.overlays; - }; - - nixosConfigurations = let - fullNixOSModules = - defaultModules - ++ [ - baseHomeModule - { - home-manager.users.michael = import ./user/environments/nixos/home.nix; - } - ]; - in { - kitchen = nixpkgs.lib.nixosSystem { - system = utils.lib.system.x86_64-linux; - modules = - fullNixOSModules - ++ [ - ./modules/common.nix - ./modules/containers.nix - - ./machines/kitchen/configuration.nix - ]; - specialArgs = {inherit inputs;}; - }; - - thinkcentre = nixpkgs.lib.nixosSystem { - system = utils.lib.system.x86_64-linux; - modules = - fullNixOSModules - ++ [ - ./modules/common.nix - ./modules/hyprland.nix - ./modules/containers.nix - - ./machines/thinkcentre/configuration.nix - agenix.nixosModules.default - { - environment.systemPackages = [ - agenix.packages.x86_64-linux.default - ]; - } - ]; - specialArgs = {inherit inputs;}; - }; - - terra = nixpkgs.lib.nixosSystem { - system = utils.lib.system.x86_64-linux; - modules = - fullNixOSModules - ++ [ - ./modules/common.nix - ./modules/hyprland.nix - ./modules/containers.nix - ./modules/applications/steam - - ./machines/terra/configuration.nix - agenix.nixosModules.default - { - environment.systemPackages = [ - agenix.packages.x86_64-linux.default - ]; - } - ]; - specialArgs = {inherit inputs;}; - }; - - oracle = nixpkgs.lib.nixosSystem { - system = utils.lib.system.x86_64-linux; - modules = - defaultModules - ++ [ - ./modules/nix.nix - baseHomeModule - { - home-manager.users.michael = import ./user/environments/nixos-server/home.nix; - } - agenix.nixosModules.default - { - environment.systemPackages = [ - agenix.packages.x86_64-linux.default - ]; - } - - ./machines/oracle/configuration.nix - ]; - specialArgs = {inherit inputs;}; - }; - }; - - darwinConfigurations = { - mac = darwin.lib.darwinSystem { - system = "aarch64-darwin"; - specialArgs = {inherit inputs;}; - modules = [ - self.overlaysModule - home-manager.darwinModules.home-manager - baseHomeModule - { - home-manager.users.michael = import ./user/environments/mac/home.nix; - } - - ./modules/yabai.nix - ./machines/mac/configuration.nix - ]; - }; - }; - - homeConfigurations = { - nixos = inputs.home-manager.lib.homeManagerConfiguration { - system = "x86_64-linux"; - homeDirectory = "/home/michael"; - username = "michael"; - stateVersion = "21.05"; - configuration = { - config, - pkgs, - ... - }: { - programs.home-manager.enable = true; - - imports = [ - ./user/environments/nixos/home.nix - ]; - }; - }; - - mac = inputs.home-manager.lib.homeManagerConfiguration { - system = "aarch64-darwin"; - homeDirectory = "/Users/michael"; - username = "michael"; - stateVersion = "22.05"; - configuration = { - config, - pkgs, - ... - }: { - programs.home-manager.enable = true; - - imports = [ - ./user/environments/mac/home.nix - ]; - }; - }; - }; - }; - # // utils.lib.eachSystem [ "aarch64-linux" "x86_64-darwin" "x86_64-linux" ] (system: { - # nixpkgs = import nixpkgs { - # inherit system; - # overlays = [ - # self.overlays.default - # ]; - # config.allowUnfree = true; - # }; - # }); } diff --git a/flakes/darwin.nix b/flakes/darwin.nix new file mode 100644 index 0000000..9f8f1f3 --- /dev/null +++ b/flakes/darwin.nix @@ -0,0 +1,44 @@ +{ + inputs, + withSystem, + ... +}: let + mkDarwin = { + system ? "aarch64-darwin", + modules ? [], + }: + withSystem system ( + { + inputs', + lib, + pkgs, + system, + ... + }: + inputs.darwin.lib.darwinSystem { + inherit system; + specialArgs = { + inherit + inputs + inputs' + lib + pkgs + ; + }; + modules = [../darwin] ++ modules; + } + ); +in { + flake.darwinConfigurations = { + mac = mkDarwin { + modules = [ + { + hm = import ../user/environments/mac/home.nix; + } + + ../modules/yabai.nix + ../machines/mac/configuration.nix + ]; + }; + }; +} diff --git a/flakes/default.nix b/flakes/default.nix new file mode 100644 index 0000000..a4fa22d --- /dev/null +++ b/flakes/default.nix @@ -0,0 +1,9 @@ +{ + imports = [ + ./lib.nix + ./darwin.nix + ./nixos.nix + ./packages.nix + ./treefmt.nix + ]; +} diff --git a/flakes/lib.nix b/flakes/lib.nix new file mode 100644 index 0000000..057a726 --- /dev/null +++ b/flakes/lib.nix @@ -0,0 +1,30 @@ +{ + perSystem = { + inputs', + config, + pkgs, + ... + }: let + # use nixpkgs lib instead of flake-parts lib + # avoids home-manager warning about version mismatch + inherit (pkgs) lib; + in { + _module.args.lib = lib.extend ( + final: prev: { + my = let + lib = final; + getPaths = file: root: + builtins.filter builtins.pathExists ( + map (dir: root + "/${dir}/${file}") ( + lib.attrNames (lib.filterAttrs (name: type: type == "directory") (builtins.readDir root)) + ) + ); + in { + inherit getPaths; + getModules = builtins.concatMap (getPaths "default.nix"); + getHmModules = builtins.concatMap (getPaths "home.nix"); + }; + } + ); + }; +} diff --git a/flakes/nixos.nix b/flakes/nixos.nix new file mode 100644 index 0000000..781ceda --- /dev/null +++ b/flakes/nixos.nix @@ -0,0 +1,107 @@ +{ + inputs, + self, + withSystem, + ... +}: let + mkNixos = { + system ? "x86_64-linux", + nixpkgs ? inputs.nixpkgs, + config ? {}, + overlays ? [], + modules ? [], + }: + withSystem system ( + { + inputs', + lib, + pkgs, + system, + ... + }: let + customPkgs = import nixpkgs ( + lib.recursiveUpdate { + inherit system; + overlays = (builtins.attrValues self.overlays) ++ overlays; + config.allowUnfree = true; + } {inherit config;} + ); + in + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { + inherit inputs inputs' lib; + pkgs = + if (nixpkgs != inputs.nixpkgs || config != {} || overlays != []) + then customPkgs + else pkgs; + }; + modules = [../nixos] ++ modules; + } + ); +in { + flake.nixosConfigurations = let + defaultModules = [ + ../modules + inputs.agenix.nixosModules.default + { + environment.systemPackages = [ + inputs.agenix.packages.x86_64-linux.default + ]; + } + ]; + + fullNixOSModules = + defaultModules + ++ [ + { + home-manager.users.michael = import ../user/environments/nixos/home.nix; + } + ]; + in { + kitchen = mkNixos { + modules = + fullNixOSModules + ++ [ + ../modules/common.nix + ../modules/containers.nix + + ../machines/kitchen/configuration.nix + ]; + }; + + thinkcentre = mkNixos { + modules = + fullNixOSModules + ++ [ + ../modules/common.nix + ../modules/containers.nix + + ../machines/thinkcentre/configuration.nix + ]; + }; + + terra = mkNixos { + modules = + fullNixOSModules + ++ [ + ../modules/common.nix + ../modules/containers.nix + + ../machines/terra/configuration.nix + ]; + }; + + oracle = mkNixos { + modules = + defaultModules + ++ [ + { + home-manager.users.michael = import ../user/environments/nixos-server/home.nix; + } + + ../machines/oracle/configuration.nix + ]; + }; + }; +} diff --git a/flakes/packages.nix b/flakes/packages.nix new file mode 100644 index 0000000..ec62422 --- /dev/null +++ b/flakes/packages.nix @@ -0,0 +1,23 @@ +{ + self, + inputs, + ... +}: { + perSystem = { + lib, + system, + ... + }: let + pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = builtins.attrValues self.overlays; + }; + in { + _module.args.pkgs = pkgs; + + packages = import ../pkgs { + inherit inputs pkgs; + }; + }; +} diff --git a/flakes/treefmt.nix b/flakes/treefmt.nix new file mode 100644 index 0000000..a4336f9 --- /dev/null +++ b/flakes/treefmt.nix @@ -0,0 +1,8 @@ +{inputs, ...}: { + imports = [inputs.treefmt-nix.flakeModule]; + + perSystem.treefmt = { + projectRootFile = "flake.nix"; + programs.alejandra.enable = true; + }; +} diff --git a/machines/kitchen/configuration.nix b/machines/kitchen/configuration.nix index 54d32b8..8d847d2 100644 --- a/machines/kitchen/configuration.nix +++ b/machines/kitchen/configuration.nix @@ -46,6 +46,8 @@ programs.zsh.enable = true; + my.hyprland.enable = true; + # Define a user account. Don't forget to set a password with ‘passwd’. users.users.michael = { isNormalUser = true; diff --git a/machines/mac/configuration.nix b/machines/mac/configuration.nix index 1ebbcd4..47514eb 100644 --- a/machines/mac/configuration.nix +++ b/machines/mac/configuration.nix @@ -56,27 +56,6 @@ nix-daemon.enable = true; }; - nixpkgs = { - # Workaround for pyopenssl being marked broken - config.allowBroken = true; - }; - - nix = { - package = pkgs.nix; - gc = { - automatic = true; - interval.Day = 7; - options = "--delete-older-than 7d"; - }; - extraOptions = '' - experimental-features = nix-command flakes - ''; - settings = { - auto-optimise-store = false; - trusted-users = ["root" "michael"]; - }; - }; - system = { # Since it's not possible to declare default shell, run this command after build activationScripts.postActivation.text = ''sudo chsh -s ${pkgs.zsh}/bin/zsh''; diff --git a/machines/terra/configuration.nix b/machines/terra/configuration.nix index 7c90e83..6b4a2ed 100644 --- a/machines/terra/configuration.nix +++ b/machines/terra/configuration.nix @@ -47,6 +47,10 @@ programs.zsh.enable = true; environment.variables.EDITOR = "nvim"; + my.hyprland.enable = true; + my.libreoffice.enable = true; + my.steam.enable = true; + # Define a user account. Don't forget to set a password with ‘passwd’. users.users.michael = { isNormalUser = true; diff --git a/machines/thinkcentre/configuration.nix b/machines/thinkcentre/configuration.nix index 4da7a28..443a6a4 100644 --- a/machines/thinkcentre/configuration.nix +++ b/machines/thinkcentre/configuration.nix @@ -114,6 +114,9 @@ firewallInterface = "wg0"; }; + # TODO: Disable desktop + my.hyprland.enable = true; + my.services.forgejo = { enable = true; port = 3000; diff --git a/modules/applications/libreoffice/default.nix b/modules/applications/libreoffice/default.nix deleted file mode 100644 index 1bf0d54..0000000 --- a/modules/applications/libreoffice/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [ - libreoffice-qt - hunspell - hunspellDicts.uk_UA - hunspellDicts.th_TH - ]; -} diff --git a/modules/applications/steam/default.nix b/modules/applications/steam/default.nix deleted file mode 100644 index 01a2b5f..0000000 --- a/modules/applications/steam/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{pkgs, ...}: { - programs.steam = { - enable = true; - package = pkgs.unstable.steam; - gamescopeSession.enable = true; - }; -} diff --git a/modules/common.nix b/modules/common.nix index f74e9ce..b468686 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -7,7 +7,6 @@ ./flatpak.nix ./fonts.nix ./hosts.nix - ./nix.nix ./sound.nix ]; } diff --git a/modules/default.nix b/modules/default.nix index 4ffe14a..f35bfde 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,6 +1,5 @@ { imports = [ - ./server ./services ]; } diff --git a/modules/hyprland.nix b/modules/hyprland.nix deleted file mode 100644 index 2b4275c..0000000 --- a/modules/hyprland.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ - pkgs, - inputs, - ... -}: let - pkgs-hyprland = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}; -in { - programs.hyprland = { - enable = true; - package = inputs.hyprland.packages.${pkgs.system}.hyprland; - }; - - hardware.opengl = { - package = pkgs-hyprland.mesa.drivers; - driSupport32Bit = true; - package32 = pkgs-hyprland.pkgsi686Linux.mesa.drivers; - }; - - services.gnome.gnome-keyring.enable = true; - security.pam.services.greetd.enableGnomeKeyring = true; - - environment.systemPackages = with pkgs; [ - # Theme - adw-gtk3 - - # Applications - gnome.nautilus - gnome.sushi - gnome.eog - gnome.totem - gnome.cheese - gnome.file-roller - gnome.gnome-weather - gnome.gnome-contacts - gnome.gnome-calendar - gnome.gnome-screenshot - gnome.gnome-dictionary - gnome.gnome-font-viewer - gnome.gnome-system-monitor - monophony # music player - - # Nvim clipboard - wl-clipboard - ]; - - # Required for Nautilus to work outside GNOME - services.gvfs.enable = true; - - # Use CAPSLOCK as Hyper key - services.keyd = { - enable = true; - keyboards.default = { - ids = ["*"]; - settings.main = { - capslock = "overload(meta, esc)"; - }; - }; - }; - - services.greetd = { - enable = true; - settings = { - default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland"; - user = "greeter"; - }; - }; - }; -} diff --git a/modules/nix.nix b/modules/nix.nix deleted file mode 100644 index 173fcf7..0000000 --- a/modules/nix.nix +++ /dev/null @@ -1,23 +0,0 @@ -{pkgs, ...}: { - nix = { - extraOptions = '' - experimental-features = flakes nix-command - ''; - # this is required until nix 2.4 is released - package = pkgs.nixFlakes; - - settings = { - auto-optimise-store = true; - trusted-users = ["root" "michael"]; - }; - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - }; - - nixpkgs.config = { - allowUnfree = true; - }; -} diff --git a/nixos/ags/home.nix b/nixos/ags/home.nix new file mode 100644 index 0000000..dc3f237 --- /dev/null +++ b/nixos/ags/home.nix @@ -0,0 +1,45 @@ +{ + inputs, + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.ags; +in { + imports = [inputs.ags.homeManagerModules.default]; + + options.my.ags = { + enable = mkEnableOption "ags"; + }; + + config = mkIf cfg.enable { + programs.ags = { + enable = true; + + extraPackages = with pkgs; [ + bun + which + fzf + # inputs.matugen.packages.${system}.default + slurp + wf-recorder + wl-clipboard + wayshot + swappy + hyprpicker + pavucontrol + networkmanager + gtk3 + ]; + }; + + home.packages = with pkgs; [ + brightnessctl + fd + dart-sass + swww + ]; + }; +} diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..366d199 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,14 @@ +{ + inputs, + lib, + ... +}: { + imports = + [ + inputs.home-manager.nixosModules.home-manager + ../common + ] + ++ lib.my.getModules [./.]; + + hm.imports = lib.my.getHmModules [./.]; +} diff --git a/nixos/hyprland/default.nix b/nixos/hyprland/default.nix new file mode 100644 index 0000000..268c4c0 --- /dev/null +++ b/nixos/hyprland/default.nix @@ -0,0 +1,81 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + pkgs-hyprland = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}; + cfg = config.my.hyprland; +in { + options.my.hyprland = { + enable = mkEnableOption "hyprland"; + }; + + config = mkIf cfg.enable { + hm.my.hyprland.enable = true; + + programs.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + }; + + hardware.opengl = { + package = pkgs-hyprland.mesa.drivers; + driSupport32Bit = true; + package32 = pkgs-hyprland.pkgsi686Linux.mesa.drivers; + }; + + services.gnome.gnome-keyring.enable = true; + security.pam.services.greetd.enableGnomeKeyring = true; + + environment.systemPackages = with pkgs; [ + # Theme + adw-gtk3 + + # Applications + gnome.nautilus + gnome.sushi + gnome.eog + gnome.totem + gnome.cheese + gnome.file-roller + gnome.gnome-weather + gnome.gnome-contacts + gnome.gnome-calendar + gnome.gnome-screenshot + gnome.gnome-dictionary + gnome.gnome-font-viewer + gnome.gnome-system-monitor + monophony # music player + + # Nvim clipboard + wl-clipboard + ]; + + # Required for Nautilus to work outside GNOME + services.gvfs.enable = true; + + # Use CAPSLOCK as Hyper key + services.keyd = { + enable = true; + keyboards.default = { + ids = ["*"]; + settings.main = { + capslock = "overload(meta, esc)"; + }; + }; + }; + + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland"; + user = "greeter"; + }; + }; + }; + }; +} diff --git a/nixos/hyprland/home.nix b/nixos/hyprland/home.nix new file mode 100644 index 0000000..d8620d5 --- /dev/null +++ b/nixos/hyprland/home.nix @@ -0,0 +1,236 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.hyprland; +in { + imports = [ + inputs.hyprland.homeManagerModules.default + ]; + + options.my.hyprland = { + enable = mkEnableOption "hyprland"; + }; + + config = mkIf cfg.enable { + my.ags.enable = true; + my.wofi.enable = true; + + home.packages = with pkgs; [ + pavucontrol + swaybg + ]; + + wayland.windowManager.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + settings = let + # No gaps or border when only one window + no_gaps_when_only = 1; + in { + "$mod" = "SUPER"; + general = { + gaps_in = 5; + gaps_out = 10; + }; + input = { + follow_mouse = 2; + }; + dwindle = { + inherit no_gaps_when_only; + }; + master = { + inherit no_gaps_when_only; + }; + exec-once = [ + "hyprctl setcursor Adwaita 24" + "ags" + "swaybg -i /home/michael/Photos/wallpaper.jpg" + "hypridle" + ]; + bind = + [ + # Program launcher + "$mod, SPACE, exec, wofi --show drun" + # Program shortcuts + "$mod, F, exec, firefox" + "$mod, Q, killactive" + "$mod, T, exec, foot" + ", Print, exec, grimblast copy area" + # Windows + "$mod, H, movefocus, l" + "$mod, J, movefocus, d" + "$mod, K, movefocus, u" + "$mod, L, movefocus, r" + # Moving windows + "$mod SHIFT, H, movewindow, l" + "$mod SHIFT, J, movewindow, d" + "$mod SHIFT, K, movewindow, u" + "$mod SHIFT, L, movewindow, r" + ] + ++ ( + # workspaces + # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} + builtins.concatLists (builtins.genList ( + x: let + ws = let + c = (x + 1) / 10; + in + builtins.toString (x + 1 - (c * 10)); + in [ + "$mod, ${ws}, workspace, ${toString (x + 1)}" + "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" + ] + ) + 10) + ); + }; + extraConfig = '' + # will switch to a submap called resize + bind=$mod,R,submap,resize + + # media controls + bindel=, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ + bindel=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- + bindl=, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + + # will start a submap called "resize" + submap=resize + + # sets repeatable binds for resizing the active window + binde=,h,resizeactive,-10 0 + binde=,j,resizeactive,0 10 + binde=,k,resizeactive,0 -10 + binde=,l,resizeactive,10 0 + + # use reset to go back to the global submap + bind=,escape,submap,reset + + # will reset the submap, meaning end the current one and return to the global one + submap=reset + ''; + }; + + gtk = { + enable = true; + font.name = "Inter 11"; + theme = { + name = "adw-gtk3-dark"; + package = pkgs.adw-gtk3; + }; + iconTheme = { + name = "Papirus"; + package = pkgs.papirus-icon-theme; + }; + }; + + home.pointerCursor = { + gtk.enable = true; + name = "Adwaita"; + package = pkgs.gnome.adwaita-icon-theme; + size = 24; + }; + + programs.hyprlock = { + enable = true; + settings = { + general = { + no_fade_in = false; + grace = 0; + disable_loading_bar = true; + }; + background = { + monitor = ""; + path = "~/Photos/wallpaper.jpg"; + blur_passes = 3; + contrast = 0.8916; + brightness = 0.8172; + vibrancy = 0.1696; + vibrancy_darkness = 0.0; + }; + input-field = { + monitor = ""; + size = "250, 60"; + outline_thickness = 2; + dots_size = 0.2; # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 0.2; # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true; + outer_color = "rgba(0, 0, 0, 0)"; + inner_color = "rgba(0, 0, 0, 0.5)"; + font_color = "rgb(200, 200, 200)"; + fade_on_empty = false; + font_family = "Inter"; + placeholder_text = "Enter Password"; + hide_input = false; + position = "0, 375"; + halign = "center"; + valign = "bottom"; + }; + label = [ + # Time + { + monitor = ""; + text = "cmd[update:1000] echo \"$(date +\"%-I:%M %P\")\""; + color = "rgba(255, 255, 255, 0.6)"; + font_size = 120; + font_family = "Inter ExtraBold"; + position = "0, -300"; + halign = "center"; + valign = "top"; + } + # User + { + monitor = ""; + text = config.my.name; + color = "rgba(255, 255, 255, 0.6)"; + font_size = 24; + font_family = "Inter Semibold"; + position = "0, 450"; + halign = "center"; + valign = "bottom"; + } + ]; + }; + }; + + services.hypridle = { + enable = true; + settings = { + general = { + lock_cmd = "pidof hyprlock || hyprlock"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + }; + + listener = [ + # Dim screen + { + timeout = 150; # 2.5 min + on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor. + on-resume = "brightnessctl -r"; # monitor backlight restore. + } + # Lock + { + timeout = 300; # 5 min + on-timeout = "loginctl lock-session"; + } + # Turn off screen + { + timeout = 330; # 5.5 min + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + # Suspend + { + timeout = 1800; # 30 min + on-timeout = "systemctl suspend"; + } + ]; + }; + }; + }; +} diff --git a/nixos/libreoffice/default.nix b/nixos/libreoffice/default.nix new file mode 100644 index 0000000..d702105 --- /dev/null +++ b/nixos/libreoffice/default.nix @@ -0,0 +1,22 @@ +{ + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.libreoffice; +in { + options.my.libreoffice = { + enable = mkEnableOption "libreoffice"; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + libreoffice-qt + hunspell + hunspellDicts.uk_UA + hunspellDicts.th_TH + ]; + }; +} diff --git a/modules/server/default.nix b/nixos/server/default.nix similarity index 100% rename from modules/server/default.nix rename to nixos/server/default.nix diff --git a/nixos/steam/default.nix b/nixos/steam/default.nix new file mode 100644 index 0000000..98a977f --- /dev/null +++ b/nixos/steam/default.nix @@ -0,0 +1,21 @@ +{ + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.steam; +in { + options.my.steam = { + enable = mkEnableOption "steam"; + }; + + config = mkIf cfg.enable { + programs.steam = { + enable = true; + package = pkgs.unstable.steam; + gamescopeSession.enable = true; + }; + }; +} diff --git a/nixos/wofi/home.nix b/nixos/wofi/home.nix new file mode 100644 index 0000000..17f0709 --- /dev/null +++ b/nixos/wofi/home.nix @@ -0,0 +1,18 @@ +{ + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.wofi; +in { + options.my.wofi = { + enable = mkEnableOption "wofi"; + }; + + config = mkIf cfg.enable { + programs.wofi = { + enable = true; + }; + }; +} diff --git a/user/environments/nixos/home.nix b/user/environments/nixos/home.nix index c41636a..a70fec6 100644 --- a/user/environments/nixos/home.nix +++ b/user/environments/nixos/home.nix @@ -1,13 +1,11 @@ { imports = [ - ../../modules/ags ../../modules/dev.nix ../../modules/firefox.nix ../../modules/fonts.nix ../../modules/foot.nix ../../modules/git.nix ../../modules/git_nixos.nix - ../../modules/hyprland.nix ../../modules/nvim.nix ../../modules/vscode.nix ../../modules/zellij diff --git a/user/modules/ags/default.nix b/user/modules/ags/default.nix deleted file mode 100644 index adab4d1..0000000 --- a/user/modules/ags/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - inputs, - pkgs, - ... -}: { - imports = [inputs.ags.homeManagerModules.default]; - - programs.ags = { - enable = true; - - extraPackages = with pkgs; [ - bun - which - dart-sass - fd - fzf - brightnessctl - swww - # inputs.matugen.packages.${system}.default - slurp - wf-recorder - wl-clipboard - wayshot - swappy - hyprpicker - pavucontrol - networkmanager - gtk3 - ]; - }; -} diff --git a/user/modules/hyprland.nix b/user/modules/hyprland.nix deleted file mode 100644 index d1069b5..0000000 --- a/user/modules/hyprland.nix +++ /dev/null @@ -1,223 +0,0 @@ -{ - pkgs, - inputs, - ... -}: { - imports = [ - inputs.hyprland.homeManagerModules.default - ./wofi.nix - ]; - - home.packages = with pkgs; [ - pavucontrol - swaybg - ]; - - wayland.windowManager.hyprland = { - enable = true; - package = inputs.hyprland.packages.${pkgs.system}.hyprland; - settings = let - # No gaps or border when only one window - no_gaps_when_only = 1; - in { - "$mod" = "SUPER"; - general = { - gaps_in = 5; - gaps_out = 10; - }; - input = { - follow_mouse = 2; - }; - dwindle = { - inherit no_gaps_when_only; - }; - master = { - inherit no_gaps_when_only; - }; - exec-once = [ - "hyprctl setcursor Adwaita 24" - "ags" - "swaybg -i /home/michael/Photos/wallpaper.jpg" - "hypridle" - ]; - bind = - [ - # Program launcher - "$mod, SPACE, exec, wofi --show drun" - # Program shortcuts - "$mod, F, exec, firefox" - "$mod, Q, killactive" - "$mod, T, exec, foot" - ", Print, exec, grimblast copy area" - # Windows - "$mod, H, movefocus, l" - "$mod, J, movefocus, d" - "$mod, K, movefocus, u" - "$mod, L, movefocus, r" - # Moving windows - "$mod SHIFT, H, movewindow, l" - "$mod SHIFT, J, movewindow, d" - "$mod SHIFT, K, movewindow, u" - "$mod SHIFT, L, movewindow, r" - ] - ++ ( - # workspaces - # binds $mod + [shift +] {1..10} to [move to] workspace {1..10} - builtins.concatLists (builtins.genList ( - x: let - ws = let - c = (x + 1) / 10; - in - builtins.toString (x + 1 - (c * 10)); - in [ - "$mod, ${ws}, workspace, ${toString (x + 1)}" - "$mod SHIFT, ${ws}, movetoworkspace, ${toString (x + 1)}" - ] - ) - 10) - ); - }; - extraConfig = '' - # will switch to a submap called resize - bind=$mod,R,submap,resize - - # media controls - bindel=, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ - bindel=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- - bindl=, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle - - # will start a submap called "resize" - submap=resize - - # sets repeatable binds for resizing the active window - binde=,h,resizeactive,-10 0 - binde=,j,resizeactive,0 10 - binde=,k,resizeactive,0 -10 - binde=,l,resizeactive,10 0 - - # use reset to go back to the global submap - bind=,escape,submap,reset - - # will reset the submap, meaning end the current one and return to the global one - submap=reset - ''; - }; - - gtk = { - enable = true; - font.name = "Inter 11"; - theme = { - name = "adw-gtk3-dark"; - package = pkgs.adw-gtk3; - }; - iconTheme = { - name = "Papirus"; - package = pkgs.papirus-icon-theme; - }; - }; - - home.pointerCursor = { - gtk.enable = true; - name = "Adwaita"; - package = pkgs.gnome.adwaita-icon-theme; - size = 24; - }; - - programs.hyprlock = { - enable = true; - settings = { - general = { - no_fade_in = false; - grace = 0; - disable_loading_bar = true; - }; - background = { - monitor = ""; - path = "~/Photos/wallpaper.jpg"; - blur_passes = 3; - contrast = 0.8916; - brightness = 0.8172; - vibrancy = 0.1696; - vibrancy_darkness = 0.0; - }; - input-field = { - monitor = ""; - size = "250, 60"; - outline_thickness = 2; - dots_size = 0.2; # Scale of input-field height, 0.2 - 0.8 - dots_spacing = 0.2; # Scale of dots' absolute size, 0.0 - 1.0 - dots_center = true; - outer_color = "rgba(0, 0, 0, 0)"; - inner_color = "rgba(0, 0, 0, 0.5)"; - font_color = "rgb(200, 200, 200)"; - fade_on_empty = false; - font_family = "Inter"; - placeholder_text = "Enter Password"; - hide_input = false; - position = "0, 375"; - halign = "center"; - valign = "bottom"; - }; - label = [ - # Time - { - monitor = ""; - text = "cmd[update:1000] echo \"$(date +\"%-I:%M %P\")\""; - color = "rgba(255, 255, 255, 0.6)"; - font_size = 120; - font_family = "Inter ExtraBold"; - position = "0, -300"; - halign = "center"; - valign = "top"; - } - # User - { - monitor = ""; - text = "Michael Thomas"; - color = "rgba(255, 255, 255, 0.6)"; - font_size = 24; - font_family = "Inter Semibold"; - position = "0, 450"; - halign = "center"; - valign = "bottom"; - } - ]; - }; - }; - - services.hypridle = { - enable = true; - settings = { - general = { - lock_cmd = "pidof hyprlock || hyprlock"; - before_sleep_cmd = "loginctl lock-session"; - after_sleep_cmd = "hyprctl dispatch dpms on"; - }; - - listener = [ - # Dim screen - { - timeout = 150; # 2.5 min - on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor. - on-resume = "brightnessctl -r"; # monitor backlight restore. - } - # Lock - { - timeout = 300; # 5 min - on-timeout = "loginctl lock-session"; - } - # Turn off screen - { - timeout = 330; # 5.5 min - on-timeout = "hyprctl dispatch dpms off"; - on-resume = "hyprctl dispatch dpms on"; - } - # Suspend - { - timeout = 1800; # 30 min - on-timeout = "systemctl suspend"; - } - ]; - }; - }; -} diff --git a/user/modules/wofi.nix b/user/modules/wofi.nix deleted file mode 100644 index e96db9a..0000000 --- a/user/modules/wofi.nix +++ /dev/null @@ -1,5 +0,0 @@ -{...}: { - programs.wofi = { - enable = true; - }; -}