Skip to content

Commit

Permalink
finish up nixosModule
Browse files Browse the repository at this point in the history
  • Loading branch information
DerDennisOP committed Aug 1, 2024
1 parent 3749b7b commit 2e62d62
Show file tree
Hide file tree
Showing 63 changed files with 2,236 additions and 2,070 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Athena OS

<h3 align="center">
💞
<a href="https://github.com/Athena-OS/athena/releases/tag/v23.11">
<a href="https://github.com/Athena-OS/athena/releases/tag/v24.05">
Download Athena OS Now
</a>
💞
Expand Down
16 changes: 8 additions & 8 deletions docs/nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ packages = with pkgs; [
```
Then, since we edited the system-level configuration file, we need to edit `sudo nano /root/.nix-channels` file and add:
```
https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager
https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz home-manager
```
(note: also nixos channel version should be set as 23.11)
(note: also nixos channel version should be set as 24.05)
and run:
```
sudo nix-channel --update
Expand All @@ -413,7 +413,7 @@ You can create a `home.nix` file referring to the actual derivation to install b
];
home.username = "athena";
home.homeDirectory = "/home/athena";
home.stateVersion = "23.11";
home.stateVersion = "24.05";
athena.desktops.xfce.refined = true;
}
```
Expand Down Expand Up @@ -448,7 +448,7 @@ The usage of `home-manager switch` command will apply the effect on the current
# The state version is required and should stay at the version you
# originally installed.
home.stateVersion = "23.11";
home.stateVersion = "24.05";
};
```

Expand Down Expand Up @@ -675,19 +675,19 @@ A very useful tool that can help you to create Nix derivations is [nix-init](htt

## Themes, Icons and Cursors

Usually, themes, icons and cursors packages could install different flavors of a specific GTK or icon theme, for example [graphite-gtk-theme](https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/data/themes/graphite-gtk-theme) could have `Graphite`, `Graphite-Dark` and other themes.
Usually, themes, icons and cursors packages could install different flavors of a specific GTK or icon theme, for example [graphite-gtk-theme](https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/data/themes/graphite-gtk-theme) could have `Graphite`, `Graphite-Dark` and other themes.

How in Nix you can know the list of all possible themes inside a GTK or icon theme package?

Let's guess we would like to have the list of all icon themes inside [tela-circle-icon-theme](https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/data/icons/tela-circle-icon-theme). The method is to build the package. Usually we can retrieve its `package.nix` package and all the needed files in the same directory, and then building it by:
Let's guess we would like to have the list of all icon themes inside [tela-circle-icon-theme](https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/data/icons/tela-circle-icon-theme). The method is to build the package. Usually we can retrieve its `package.nix` package and all the needed files in the same directory, and then building it by:
```nix
sudo nix-build -E 'with import <nixpkgs> {}; callPackage ./package.nix {}'
```
Some packages could return some error because they need to use other modules. In case of our icon theme above, it could return the error:
```
error: evaluation aborted with the following error message: 'Function called without required argument "adwaita-icon-theme" at /home/user/tela/default.nix:4'
```
To run the correct build command, you need to give a look to [all-packages.nix](https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/top-level/all-packages.nix) and search for `tela-circle-icon-theme`. You will find the following:
To run the correct build command, you need to give a look to [all-packages.nix](https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/top-level/all-packages.nix) and search for `tela-circle-icon-theme`. You will find the following:
```nix
tela-circle-icon-theme = callPackage ../data/icons/tela-circle-icon-theme {
inherit (gnome) adwaita-icon-theme;
Expand Down Expand Up @@ -773,7 +773,7 @@ gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: Cache file created successfully.
gtk-update-icon-cache: The generated cache was invalid.
error: builder for '/nix/store/gf4fp0qf42addb15xpplx472bprrczm9-system-path.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/is3avirfqcb4a59ml9y2pc5ll66mn975-nixos-system-athenaos-23.11.3640.56911ef3403a.drv' failed to build
error: 1 dependencies of derivation '/nix/store/is3avirfqcb4a59ml9y2pc5ll66mn975-nixos-system-athenaos-24.05.3640.56911ef3403a.drv' failed to build
```
it probably is caused by an icon set you are installing where one or more of its files contain a **space** inside their filename. Just rename them by removing or replacing the space by another character.

Expand Down
45 changes: 25 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ config, pkgs, ...}: let
({ lib, pkgs, config, ...}: let
hostname = "athenaos";
hashed = "$6$zjvJDfGSC93t8SIW$AHhNB.vDDPMoiZEG3Mv6UYvgUY6eya2UY5E2XA1lF7mOg6nHXUaaBmJYAMMQhvQcA54HJSLdkJ/zdy8UKX3xL1";
hashedRoot = "$6$zjvJDfGSC93t8SIW$AHhNB.vDDPMoiZEG3Mv6UYvgUY6eya2UY5E2XA1lF7mOg6nHXUaaBmJYAMMQhvQcA54HJSLdkJ/zdy8UKX3xL1";
in {
networking.hostName = "${hostname}";
users = {
users = lib.mkIf config.athena.enable {
mutableUsers = false;
extraUsers.root.hashedPassword = "${hashedRoot}";
users.${config.athena-nix.homeManagerUser} = {
shell = pkgs.${config.athena-nix.shell};
users.${config.athena.homeManagerUser} = {
shell = pkgs.${config.athena.shell};
isNormalUser = true;
hashedPassword = "${hashed}";
extraGroups = [ "wheel" "input" "video" "render" "networkmanager" ];
Expand All @@ -48,10 +48,11 @@
home-manager.nixosModules.home-manager
./nixos
{
athena-nix = {
athena = {
enable = true;
homeManagerUser = "athena";
baseHosts = true;
baseLocale = true;
homeManagerUser = "athena";
desktopManager = "mate";
terminal = "alacritty";
theme = "graphite";
Expand All @@ -64,16 +65,16 @@
home-manager.nixosModules.home-manager
./nixos
{
athena-nix = {
inherit terminal theme shell browser;
enable = true;
homeManagerUser = username;
baseConfiguration = true;
baseSoftware = true;
desktopManager = desktop;
bootLoader = bootloader;
displayManager = dmanager;
};
athena = {
inherit bootloader terminal theme shell browser;
enable = true;
baseConfiguration = true;
baseSoftware = true;
baseLocale = true;
homeManagerUser = username;
desktopManager = desktop;
displayManager = dmanager;
};
}
];

Expand All @@ -83,9 +84,13 @@
];
};

packages."x86_64-linux" =
(builtins.mapAttrs (n: v: v.config.system.build.isoImage) self.nixosConfigurations) // {
default = self.packages."x86_64-linux"."live-image";
};
packages."x86_64-linux" = (builtins.mapAttrs (n: v: v.config.system.build.isoImage) self.nixosConfigurations) // {
default = self.packages."x86_64-linux"."live-image";
};

nixosModules = rec {
athena = ./nixos;
default = athena;
};
};
}
70 changes: 36 additions & 34 deletions nixos/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:
{ lib, config, pkgs, ... }:
let
# These variable names are used by Aegis backend
version = "unstable"; #or 24.05
Expand All @@ -17,42 +17,44 @@ let
terminal = "kitty";
browser = "firefox";
bootloader = if builtins.pathExists "/sys/firmware/efi" then "systemd" else "grub";
hm-version = if version == "unstable" then "master" else "release-"version; # "master" or "release-23.11"; # Correspond to home-manager GitHub branches
hm-version = if version == "unstable" then "master" else "release-"version; # "master" or "release-24.05"; # Correspond to home-manager GitHub branches
home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/${hm-version}.tar.gz";
in
{
imports =
[ # Include the results of the hardware scan.
{
_module.args.version = version;
_module.args.username = username;
_module.args.hashed = hashed;
_module.args.hashedRoot = hashedRoot;
_module.args.hostname = hostname;
_module.args.theme = theme;
_module.args.desktop = desktop;
_module.args.dmanager = dmanager;
_module.args.shell = shell;
_module.args.terminal = terminal;
_module.args.browser = browser;
_module.args.bootloader = bootloader;
}
(import "${home-manager}/nixos")
/etc/nixos/hardware-configuration.nix
./modules/boot/${bootloader}
./modules/dms/${dmanager}
./modules/themes/${theme}
./home-manager/desktops/${desktop}
./home-manager/terminals/${terminal}
./home-manager/browsers/${browser}
./home-manager/shells/${shell}
./hosts/software
./.
imports = [ # Include the results of the hardware scan.
{
athena = {
inherit bootloader terminal theme shell browser;
enable = true;
homeManagerUser = username;
baseConfiguration = true;
baseSoftware = true;
baseLocale = true;
desktopManager = desktop;
displayManager = dmanager;
};
}
(import "${home-manager}/nixos")
/etc/nixos/hardware-configuration.nix
./.

];

users = lib.mkIf config.athena.enable {
mutableUsers = false;
extraUsers.root.hashedPassword = "${hashedRoot}";
users.${config.athena.homeManagerUser} = {
shell = pkgs.${config.athena.shell};
isNormalUser = true;
hashedPassword = "${hashed}";
extraGroups = [ "wheel" "input" "video" "render" "networkmanager" ];
};
};

networking = {
hostName = "${hostname}";
enableIPv6 = false;
};

];
networking.enableIPv6 = false;
services.flatpak.enable = true;
networking.extraHosts =
''
'';
}
42 changes: 23 additions & 19 deletions nixos/default.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{ lib, config, ... }@inputs: let
cfg = config.athena-nix;
cfg = config.athena;
in {
options = {
athena-nix = {
enable = lib.mkEnableOption "Enable athena-nix";
athena = {
enable = lib.mkEnableOption "Enable Athena";
baseConfiguration = lib.mkEnableOption "Enable base configuration";
baseSoftware = lib.mkEnableOption "Enable base software";
baseLocale = lib.mkEnableOption "Enable base locale";
baseHosts = lib.mkEnableOption "Make base changes. Such as setting the stateVersion.";
homeManagerUser = lib.mkOption {
type = lib.types.str;
default = "athena";
description = ''
The user to use for home-manager.
'';
Expand Down Expand Up @@ -41,6 +42,12 @@ in {
'';
};

theme-components = lib.mkOption {
type = lib.types.attrs;
description = "The components of the theme to use. Internal use.";
visible = false;
};

desktopManager = lib.mkOption {
type = with lib.types; nullOr (enum [
"axyl"
Expand Down Expand Up @@ -103,21 +110,18 @@ in {
};
};

config = lib.mkIf cfg.athena-nix.enable (let
imports = lib.optionals cfg.baseConfiguration [
./home-manager
./modules
./pkgs
] ++ [ ./modules/themes/${cfg.theme} ]
++ (lib.optional (cfg.desktopManager != null) ./home-manager/desktops/${cfg.desktopManager})
++ lib.optional (cfg.displayManager != null) ./modules/dms/${cfg.displayManager}
++ lib.optional (cfg.shell != null) ./home-manager/shells/${cfg.shell}
++ lib.optional (cfg.terminal != null) ./home-manager/terminals/${cfg.terminal}
++ lib.optional (cfg.browser != null) ./home-manager/browsers/${cfg.browser}
++ lib.optional (cfg.bootloader != null) ./modules/boot/${cfg.bootloader}
++ lib.optional cfg.baseSoftware ./hosts/software
++ lib.optional cfg.baseLocale ./hosts/locale
++ lib.optional cfg.baseHosts ./hosts;
in lib.mergeAttrsList (map (v: import v inputs) imports));
imports = [
./home-manager
./modules
./pkgs
./modules/themes
./home-manager/desktops
./modules/dms
./home-manager/shells
./home-manager/terminals
./home-manager/browsers
./modules/boot
./hosts
];
}

5 changes: 5 additions & 0 deletions nixos/home-manager/browsers/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ ... }: {
imports = [
./firefox
];
}
Loading

0 comments on commit 2e62d62

Please sign in to comment.