Athena-OS / athena-nix

Athena OS Nix configuration files focused on Cybersecurity. Learn, practice and enjoy with any hacking tool!
https://athenaos.org
MIT License
109 stars 11 forks source link

[ENHANCEMENT]: Use nixosModules #13

Open DerDennisOP opened 1 month ago

DerDennisOP commented 1 month ago

I would like to import this as a nixosModule to my existing Configuration.

D3vil0p3r commented 1 month ago

Try to use flakes

DerDennisOP commented 1 month ago

I'm using flakes. How do I use it with my existing configuration?

D3vil0p3r commented 1 month ago

U should integrate some expressions in configuration.nix file of Athena and put in your configuration file and importing all the structure (files and folders)

DerDennisOP commented 1 month ago

image I have a many servers, services and users in configuration.nix. Changing the entire structure is too much work. just copying the files from athena is also a lot of work. espacially if it has to be done over and over again for each individual person that is already using nix. A nixosModule would be the best way to add configutations to ones system. My entire configuration has 6181 lines of nix code, adapting to use athena (what I really would like), would be some much easier if I only would do athena = { enable = true; shell = "zsh"; ... }

D3vil0p3r commented 1 month ago

Mmh, currently my Nix exp does not involve NixOSModules. Can you try to create it?

DerDennisOP commented 1 month ago

I mean I can try. Also is there going to be hyperland? There is also this project: https://github.com/end-4/dots-hyprland

D3vil0p3r commented 1 month ago

I have a Hyprland theme to use. The problem is that it needs to write on files that in NixOS are intended to be read-only. If there is a simple dotfiles tested and working, I can implement in Athena Nix.

DerDennisOP commented 1 month ago

I have a Hyprland theme to use. The problem is that it needs to write on files that in NixOS are intended to be read-only. If there is a simple dotfiles tested and working, I can implement in Athena Nix.

Whats the problem exactly. Can you link some code where you want to write?

D3vil0p3r commented 1 month ago

This is the env I would like to integrate: https://github.com/end-4/dots-hyprland

DerDennisOP commented 1 month ago

I can make 3 PRs by next week:

DerDennisOP commented 3 weeks ago

@D3vil0p3r can you review #16 and maybe you could try to add hyperland? It was already much work to refactor big parts of the code, and I'm still not done yet.

D3vil0p3r commented 2 weeks ago

It is long to review, but I see that you refactored the code for Athena Nix Flake in order to make it more flexible... But since you edited several default.nix files, are you tested if it still works in case a user uses nixos-rebuild switch with the configuration.nix file instead of flakes?

I tested it now by using the configuration.nix file and I get:

error: The option `athena-nix.homeManagerUser' is used but not defined.

If the proposal does not work both for configuration.nix and flakes, I cannot merge the related PR.

DerDennisOP commented 2 weeks ago

How have you tested it? Afaik it should work with both, I have tested it and it worked for me. The error you are describing occures, when athena-nix.homeManagerUser is not set. I'll put in defaults, so this error won't happen anymore. You can try again.

D3vil0p3r commented 2 weeks ago

how have you tested it. Afaik it should work with both, I have tested it and it worked for me. The error you are describing occures, when athena-nix.homeManagerUser is not set. I'll put in defaults, so this error won't happen anymore.

I expected that error because in configuration.nix it should be set. By the way I just cloned your forked repository, I copied all files in /etc/nixos and I run sudo nixos-rebuild switch.

D3vil0p3r commented 2 weeks ago

Note that all the changes done by the users must be tweaked in only configuration.nix because this file is connected to the Athena installer.

DerDennisOP commented 2 weeks ago

Oh you are right. I haven't touched the configuration nix stuff. I can fix it really quick.

DerDennisOP commented 2 weeks ago

Ok, should hopefully be fixed. please test it once again.

D3vil0p3r commented 2 weeks ago

Getting:

       error: attribute 'username' missing

       at /etc/nixos/modules/dev/tmux/default.nix:14:26:

           13|   config = lib.mkIf config.athena-nix.baseConfiguration {
           14|     home-manager.users.${config.athena-nix.username} = { pkgs, ... }: {
             |                          ^
           15|       programs.tmux = {
DerDennisOP commented 2 weeks ago

I'm sorry that I have to use you as a current test bench, should be fixed. Do you want the configuration option named athena-nix or just athena?

D3vil0p3r commented 2 weeks ago

Just athena

DerDennisOP commented 2 weeks ago

changed.

D3vil0p3r commented 2 weeks ago

I get:

error: The option `home-manager.users.athena.home.stateVersion' is used but not defined.
DerDennisOP commented 2 weeks ago

yup, also this is fixed. I got confused by the old config smh.

D3vil0p3r commented 2 weeks ago

Another error:

       at /etc/nixos/modules/misc/nist-feed/default.nix:4:9:

            3| let
            4|   cfg = config.services.nist-feed;
             |         ^
            5|   nistFeedPkg = pkgs.callPackage ../../../pkgs/nist-feed/package.nix { };

Can you please test on your clean NixOS machine? Otherwise I stuck at testing it several times and getting errors.

DerDennisOP commented 2 weeks ago

I dont really have a system that I can use rn, that the problem.

D3vil0p3r commented 2 weeks ago

Did you refactor all those files without testing in a system?

DerDennisOP commented 2 weeks ago

I included it in my system config. But I can't just do switching, because I don't even have an /etc/nixos/hardware-configuration.nix. I would need some clean system by any possiblity.

D3vil0p3r commented 2 weeks ago

Try to set up a VM

DerDennisOP commented 2 weeks ago

I coudn't get the VM to setup, but I figured out a way to test it.

DerDennisOP commented 2 weeks ago

WELL, that was the last error anyway xD. Please tell me if you encounter any runtime errors.

D3vil0p3r commented 2 weeks ago

Ok it seems to work. I need just to test it by the installer and cyber roles. My question: why did you propose this refactoring instead of the previous structure? What are the advantages?

DerDennisOP commented 2 weeks ago

now everything is a module. making it less a configurations, rather more a package that you can universally through at any existing configuration. I can't really explain what all the benefits of modules are, but the main advantage is that you can now change your configuration without touching this git repo / or cloneing it.

image you basically can add it in flake inputs like "home-manager", and you have all the configuration needed to use athenaos.

DerDennisOP commented 2 weeks ago

Ok it seems to work. I need just to test it by the installer and cyber roles. My question: why did you propose this refactoring instead of the previous structure? What are the advantages?

@D3vil0p3r any updates?

D3vil0p3r commented 2 weeks ago

Hey. I need to find free time to check it in deep and merge the PR. In these weeks will be hard to find time, but I try to get some dedicated moments for it.

DerDennisOP commented 6 days ago

@D3vil0p3r can you review #16 and maybe you could try to add hyperland? It was already much work to refactor big parts of the code, and I'm still not done yet.

so, have you any suggestions on using hyperland. You told me that you wanned to include an env from end-4, I didn't quite get the problem in doing it. I really enjoy the look and style of this (https://athenaos.org/en/configuration/hyperland), I'm already using hyperland, but coudn't get ags to working.

D3vil0p3r commented 6 days ago

@D3vil0p3r can you review #16 and maybe you could try to add hyperland? It was already much work to refactor big parts of the code, and I'm still not done yet.

so, have you any suggestions on using hyperland. You told me that you wanned to include an env from end-4

I did some attempts time ago but it could not be possible because of immutability of NixOS env.

DerDennisOP commented 6 days ago

@D3vil0p3r can you review #16 and maybe you could try to add hyperland? It was already much work to refactor big parts of the code, and I'm still not done yet.

so, have you any suggestions on using hyperland. You told me that you wanned to include an env from end-4

I did some attempts time ago but it could not be possible because of immutability of NixOS env.

usually this shoudn't be any problem at all. Maybe you could try again, and show me the exact errors you got, then I might be able to help you.

D3vil0p3r commented 6 days ago

The problem is that one component (I don't remember if ags) attempts to write on its installation folder (that in NixOS is under /nix/store, so read-only).

DerDennisOP commented 6 days ago

The problem is that one component (I don't remember if ags) attempts to write on its installation folder (that in NixOS is under /nix/store, so read-only).

Haven't you keeped the configurations files somewhere? So we can try to fix those errors? Sometimes programs try to write into their installation folder, but usually this can be fixed.