Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixosModules: autogenerate list of modules #3

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

arthsmn
Copy link
Contributor

@arthsmn arthsmn commented Jan 23, 2025

Created a function that creates a list of all the modules inside the programs folder. If other folders are used in the future, this function can be easily modified to be applied to each folder by mapping it.

Basically, this function reads the directory, filters all files that are "regular", picks their names (paths) and puts the parent directory in the path. When/if the pipe operator becomes stable we can use it instead of lib.pipe, making it cleaner.

Removed the programs/default.nix, as it isn't necessary anymore. Also, modified the module call in flake.nix to handle a function that receives a lib argument, as nixpkgs' lib is necessary.

@arthsmn arthsmn closed this Jan 23, 2025
@arthsmn arthsmn reopened this Jan 23, 2025
@arthsmn
Copy link
Contributor Author

arthsmn commented Jan 23, 2025

Sorry, missclicked!

@Lunarnovaa
Copy link
Collaborator

Hi! This looks fine for what it is, but it doesn't import files recursively (namely, if I have a file modules/programs/firefox/file.nix, it's not imported). Not a major issue, but limits us in terms of structure. While trying to modify the function, I stumbled across lib.filesystem.listFilesRecursive, which actually heavily simplifies the imports syntax and function.

My commits will be pushed to your branch and this PR will be merged. Thanks for your contribution :)

@Lunarnovaa Lunarnovaa merged commit 31653ee into snugnug:main Jan 24, 2025
@arthsmn arthsmn deleted the autogen-modules branch January 24, 2025 02:01
@arthsmn
Copy link
Contributor Author

arthsmn commented Jan 24, 2025

Hi! This looks fine for what it is, but it doesn't import files recursively (namely, if I have a file modules/programs/firefox/file.nix, it's not imported). Not a major issue, but limits us in terms of structure. While trying to modify the function, I stumbled across lib.filesystem.listFilesRecursive, which actually heavily simplifies the imports syntax and function.

My commits will be pushed to your branch and this PR will be merged. Thanks for your contribution :)

Thanks for the suggestion, I didn't even know such function existed lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants