Skip to content

Commit

Permalink
🚧 defaults apps and hyprland
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDR committed Nov 22, 2024
1 parent b43d119 commit cd44525
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 13 deletions.
1 change: 0 additions & 1 deletion configuration/nixos/optional/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
programs = {
onepassword = import ./programs/1password.nix;
docker = import ./programs/docker.nix;
thunar = import ./programs/thunar.nix;
};
};
}
8 changes: 0 additions & 8 deletions configuration/nixos/optional/programs/thunar.nix

This file was deleted.

58 changes: 58 additions & 0 deletions home-manager/anchor/desktop-environment.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
self,
pkgs,
...
}: let
wallpaper = "${self}/data/wallpapers/firewatch.jpg";
in {
ysomic = {
applications.defaults = {
enable = true;
browser = pkgs.floorp;
pdfReader = pkgs.sumatra;
terminal = "kitty";
fileManager = "thunar";
};

wayland.hyprland = {
enable = true;
hyprlock.enable = false;
wallpaper = wallpaper;

startupScript = {
init = ''
open_in_workspace "discord --in-progress-gpu --use-gl=desktop" 1 &
open_in_workspace "spotify" 2 &
open_in_workspace "floorp" 3 &
open_in_workspace "kitty" 4 &
'';

postInit = ''
hyprctl dispatch workspace 4 &
'';
};
};
};

wayland.windowManager.hyprland = {
settings = {
workspace = [
"name:1, monitor:DP-1, persistent:true"
"name:2, monitor:DP-2, persistent:true"
"name:3, monitor:DP-1, persistent:true"
"name:4, monitor:DP-2, persistent:true"
"name:5, monitor:DP-1, persistent:true"
"name:6, monitor:DP-2, persistent:true"
"name:7, monitor:DP-1, persistent:true"
"name:8, monitor:DP-2, persistent:true"
];

monitor = [
# Left screen
"DP-1, 2560x1440, 0x0, 1"
# Main screen
"DP-2, 2560x1440@165, 2560x0, 1"
];
};
};
}
168 changes: 168 additions & 0 deletions lib/repl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Nix REPL Guide

## Basic Usage

Start the REPL in your flake directory:
```bash
repl .
```

## Common Configurations

### Home Manager
Access home-manager configurations:
```nix
homeConfigurations."user@hostname"
```

Useful aliases for easier access:
```nix
cfg = homeConfigurations."user@hostname".config
```

### NixOS
Access NixOS configurations:
```nix
nixosConfigurations.hostname
```

Useful aliases:
```nix
cfg = nixosConfigurations.hostname.config
```

## Configuration Structure

### Home Manager Structure
- `config` - Contains the evaluated configuration
- `home` - Basic home configuration (username, homeDirectory, etc.)
- `services` - All service configurations
- `programs` - All program configurations
- `systemd` - Systemd user service configurations
- `options` - Available configuration options
- `pkgs` - Access to nixpkgs
- `extendModules` - Function to extend the configuration
- `activationPackage` - The derivation that activates the configuration

Examples:
```nix
# Basic home config
cfg.home.username
cfg.home.homeDirectory
# Services (NOT cfg.home.services)
cfg.services.dunst.enable
cfg.services.picom.enable
# Programs
cfg.programs.git.enable
cfg.programs.vim.enable
```

### NixOS Structure
- `config` - Contains the evaluated configuration
- `services` - System services
- `systemd` - Systemd configurations
- `networking` - Network configurations
- `hardware` - Hardware configurations
- `options` - Available configuration options
- `pkgs` - Access to nixpkgs

## Exploring Configurations

List available attributes:
```nix
# List all attributes in a configuration section
builtins.attrNames cfg.services
builtins.attrNames cfg.programs
builtins.attrNames cfg.home
# List all options
builtins.attrNames cfg.options
# Explore specific service options
builtins.attrNames cfg.services.dunst
```

## Common Errors

### Missing Attributes
Error: `error: attribute 'xyz' missing`
- Check if you're looking in the correct location
- Services are under `config.services`, not `config.home.services`
- Use `builtins.attrNames` to see available attributes

### Deprecated Services
Error messages about removed services (e.g., `services.keepassx`) indicate:
- The service has been removed/deprecated
- Often includes information about replacements
- These errors appear when viewing all services but won't affect your configuration

## Tips & Tricks

### Tab Completion
- Press TAB after typing partial paths to see available options
- Works with both attribute names and values

### Testing Values
```nix
# Check if a service is enabled
cfg.services.dunst.enable
# Check program settings
cfg.programs.git.userEmail
# View entire configuration for a service
cfg.services.dunst
```

### Debugging

Check if values are being set correctly:
```nix
# View the entire configuration
cfg
# View specific sections
cfg.services
cfg.programs
# Check option definitions
cfg.options.services.dunst.enable.description
```

### Using with Flakes

View flake inputs:
```nix
inputs
inputs.nixpkgs
```

View flake outputs:
```nix
outputs
outputs.packages
```

### Useful Queries

Package exploration:
```nix
# View available packages
builtins.attrNames pkgs
# Check package version
pkgs.nodejs.version
```

System information:
```nix
# NixOS
cfg.networking.hostName
cfg.system.stateVersion
# Home Manager
cfg.home.stateVersion
cfg.home.username
```
153 changes: 153 additions & 0 deletions modules/home-manager/applications/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
config,
lib,
pkgs,
...
}: let
cfg = config.ysomic.applications.defaults;

terminalPackage = config.ysomic.applications.defaults.supported.terminals.${cfg.terminal};
fileManagerPackage = config.ysomic.applications.defaults.supported.fileManagers.${cfg.fileManager};
getDesktopFile = app: "${app}.desktop";
in {
options.ysomic.applications.defaults = {
enable = lib.mkEnableOption "Default application configuration";

# Helpers for other modules
supported = lib.mkOption {
type = lib.types.attrs;
# Won't show up in documentation
internal = true;
default = {
terminals = {
kitty = pkgs.kitty;
};
fileManagers = {
thunar = pkgs.xfce.thunar;
};
};
};

# Core applications
browser = lib.mkOption {
type = lib.types.package;
default = pkgs.floorp;
description = "Default web browser";
};

terminal = lib.mkOption {
type = lib.types.enum (builtins.attrNames config.ysomic.applications.defaults.supported.terminals);
default = "kitty";
description = ''
Default terminal emulator.
Supported values: ${builtins.concatStringsSep ", " (builtins.attrNames config.ysomic.applications.defaults.supported.terminals)}
'';
};

fileManager = lib.mkOption {
type = lib.types.enum (builtins.attrNames config.ysomic.applications.defaults.supported.fileManagers);
default = "thunar";
description = ''
Default file manager.
Supported values: ${builtins.concatStringsSep ", " (builtins.attrNames config.ysomic.applications.defaults.supported.fileManagers)}
'';
};

fileManagerPlugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = with pkgs.xfce; [
thunar-archive-plugin
thunar-volman
];
description = "Plugins to enable for the filemanager, for example Thunar";
};

pdfReader = lib.mkOption {
type = lib.types.package;
default = pkgs.okular;
description = "Default PDF reader";
};

# Additional options
associations = lib.mkOption {
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
default = {};
description = "Additional mime type associations";
example = lib.literalExpression ''
{
"text/plain" = [ "org.gnome.gedit.desktop" ];
}
'';
};
};

config = lib.mkIf cfg.enable (lib.mkMerge [
{
home.packages = [
cfg.browser
cfg.pdfReader
];

xdg.mimeApps = {
enable = true;
defaultApplications = lib.mkMerge [
{
"x-scheme-handler/http" = [(getDesktopFile cfg.browser.pname)];
"x-scheme-handler/https" = [(getDesktopFile cfg.browser.pname)];
"x-scheme-handler/chrome" = [(getDesktopFile cfg.browser.pname)];
"text/html" = [(getDesktopFile cfg.browser.pname)];
"application/x-extension-htm" = [(getDesktopFile cfg.browser.pname)];
"application/x-extension-html" = [(getDesktopFile cfg.browser.pname)];
"application/x-extension-shtml" = [(getDesktopFile cfg.browser.pname)];
"application/xhtml+xml" = [(getDesktopFile cfg.browser.pname)];
"application/x-extension-xhtml" = [(getDesktopFile cfg.browser.pname)];
"application/x-extension-xht" = [(getDesktopFile cfg.browser.pname)];
}
{
"application/pdf" = [
(getDesktopFile cfg.pdfReader.pname)
(getDesktopFile cfg.browser.pname)
];
}
{
"inode/directory" = [(getDesktopFile fileManagerPackage.pname)];
"application/x-compressed-tar" = [(getDesktopFile fileManagerPackage.pname)];
}
cfg.associations
];
};

# Export environment variables
home.sessionVariables = {
BROWSER = lib.getExe cfg.browser;
TERMINAL = lib.getExe terminalPackage;
FILE_MANAGER = lib.getExe fileManagerPackage;
};
}

## FILE MANAGERS
(lib.mkIf (cfg.fileManager == "thunar") {
programs.thunar.enable = true;
programs.thunar.plugins = cfg.fileManagerPlugins;
})

## TERMINALS
(lib.mkIf (cfg.terminal == "kitty") {
programs.kitty = {
enable = true;
font.name = "JetBrainsMono Nerd Font";
font.size = 12;
settings = {
tab_bar_min_tabs = 1;
tab_title_template = "{title}{' :{}:'.format(num_windows) if num_windows > 1 else ''}";
tab_bar_edge = "bottom";
tab_bar_style = "powerline";
tab_powerline_style = "slanted";
enable_audio_bell = false;
scrollback_lines = 10000;
disable_ligatures = "never";
};
};
})
]);
}
Loading

0 comments on commit cd44525

Please sign in to comment.