Document not found (404)
+This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..f173110 --- /dev/null +++ b/.nojekyll @@ -0,0 +1 @@ +This file makes sure that Github Pages doesn't process mdBook's output. diff --git a/404.html b/404.html new file mode 100644 index 0000000..03eb81a --- /dev/null +++ b/404.html @@ -0,0 +1,189 @@ + + +
+ + +This URL is invalid, sorry. Please use the navigation bar or search to continue.
+ +Builtin Modules are modules defined with this same package.
+They are already included when we use this package.
+files.alias
, create bash script aliasfiles.cmds
, install packages from nix repositoryfiles.docs
, convert our modules file into markdown using nmdfiles.git
, configure git with file creationfiles.on-call
, connfigure file to created only when devshell-files command is called, not on shell startfiles.gitignore
, copy .gitignore from templatesfiles.hcl
, create HCL files with nix syntaxfiles.json
, create JSON files with nix syntaxfiles.mdbook
, convert your markdown files to HTML using mdbookfiles.nim
, similar to files.alias
, but compiles Nim codefiles.nus
, similar to files.alias
, but runs in Nushellfiles.nush
, similar to files.nus
, but for subcommandsfiles.services
, process supervisor for development services using s6files.rc
, WIP, process supervisor for development services using s6-rcfiles.spdx
, copy LICENSE from templatesfiles.text
, create free text files with nix syntaxfiles.toml
, create TOML files with nix syntaxfiles.watch
, create an alias and service to run command when file changes using inotify-toolsfiles.yaml
, create YAML files with nix syntaxOur documentation is generated by files.text
, files.docs
and files.mdbook
To document our modules is simple, we just need to use config.files.docs
as follow
# examples/docs.nix
+
+{lib, pkgs, ...}:
+{
+ files.docs."/gh-pages/src/modules/alias.md".modules = [ ../modules/alias.nix ];
+ files.docs."/gh-pages/src/modules/cmds.md".modules = [ ../modules/cmds.nix ];
+ files.docs."/gh-pages/src/modules/files.md".modules = [ ../modules/files.nix ];
+ files.docs."/gh-pages/src/modules/git.md".modules = [ ../modules/git.nix ];
+ files.docs."/gh-pages/src/modules/on-call.md".modules = [ ../modules/startup.nix ];
+ files.docs."/gh-pages/src/modules/gitignore.md".modules = [ ../modules/gitignore.nix ];
+ files.docs."/gh-pages/src/modules/hcl.md".modules = [ ../modules/hcl.nix ];
+ files.docs."/gh-pages/src/modules/json.md".modules = [ ../modules/json.nix ];
+ files.docs."/gh-pages/src/modules/mdbook.md".modules = [ ../modules/mdbook.nix ];
+ files.docs."/gh-pages/src/modules/nim.md".modules = [ ../modules/nim.nix ];
+ files.docs."/gh-pages/src/modules/nushell.md".modules = [ ../modules/nushell.nix ];
+ files.docs."/gh-pages/src/modules/nush.md".modules = [ ../modules/nush.nix ../modules/nuon.nix ];
+ files.docs."/gh-pages/src/modules/rc.md".modules = [ ../modules/services/rc-devshell.nix ];
+ files.docs."/gh-pages/src/modules/services.md".modules = [ ../modules/services.nix ];
+ files.docs."/gh-pages/src/modules/spdx.md".modules = [ ../modules/spdx.nix ];
+ files.docs."/gh-pages/src/modules/text.md".modules = [ ../modules/text.nix ];
+ files.docs."/gh-pages/src/modules/toml.md".modules = [ ../modules/toml.nix ];
+ files.docs."/gh-pages/src/modules/watch.md".modules = [ ../modules/watch ];
+ files.docs."/gh-pages/src/modules/yaml.md".modules = [ ../modules/yaml.nix ];
+}
+
+
+# examples/book.nix
+
+{lib, ...}:
+let
+ project = "devshell-files";
+ author = "cruel-intentions";
+ org-url = "https://github.com/${author}";
+ edit-path = "${org-url}/${project}/edit/master/examples/{path}";
+in
+{
+ files.mdbook.authors = ["Cruel Intentions <${org-url}>"];
+ files.mdbook.enable = true;
+ files.mdbook.gh-author = author;
+ files.mdbook.gh-project = project;
+ files.mdbook.language = "en";
+ files.mdbook.multilingual = false;
+ files.mdbook.summary = builtins.readFile ./summary.md;
+ files.mdbook.title = "Nix DevShell Files Maker";
+ files.mdbook.output.html.edit-url-template = edit-path;
+ files.mdbook.output.html.fold.enable = true;
+ files.mdbook.output.html.git-repository-url = "${org-url}/${project}/tree/master";
+ files.mdbook.output.html.no-section-label = true;
+ files.mdbook.output.html.site-url = "/${project}/";
+ files.gitignore.pattern.gh-pages = true;
+ files.text."/gh-pages/src/introduction.md" = builtins.readFile ./readme/about.md;
+ files.text."/gh-pages/src/installation.md" = builtins.readFile ./readme/installation.md;
+ files.text."/gh-pages/src/examples.md" = builtins.import ./readme/examples.nix;
+ files.text."/gh-pages/src/modules.md" = "## Writing new modules";
+ files.text."/gh-pages/src/nix-lang.md" = builtins.readFile ./readme/modules/nix-lang.md;
+ files.text."/gh-pages/src/json-nix.md" = builtins.import ./readme/modules/json-vs-nix.nix lib;
+ files.text."/gh-pages/src/module-spec.md" = builtins.readFile ./readme/modules/modules.md;
+ files.text."/gh-pages/src/share.md" = builtins.readFile ./readme/modules/share.md;
+ files.text."/gh-pages/src/document.md" = builtins.import ./readme/modules/document.nix;
+ files.text."/gh-pages/src/builtins.md" = builtins.readFile ./readme/modules/builtins.md;
+ files.text."/gh-pages/src/todo.md" = builtins.readFile ./readme/todo.md;
+ files.text."/gh-pages/src/issues.md" = builtins.readFile ./readme/issues.md;
+ files.text."/gh-pages/src/seeAlso.md" = builtins.readFile ./readme/seeAlso.md;
+ files.alias.publish-as-gh-pages-from-local = ''
+ # same as publish-as-gh-pages but works local
+ cd $PRJ_ROOT
+ ORIGIN=`git remote get-url origin`
+ cd gh-pages
+ mdbook build
+ cd book
+ git init .
+ git add .
+ git checkout -b gh-pages
+ git commit -m "docs(gh-pages): update gh-pages" .
+ git remote add origin $ORIGIN
+ git push -u origin gh-pages --force
+ '';
+}
+
+
+And publish this mdbook to github pages with book-as-gh-pages
alias.
Creating JSON, TEXT, TOML or YAML files
+# examples/hello.nix
+#
+# this is one nix file
+{
+ files.json."/generated/hello.json".hello = "world";
+ files.toml."/generated/hello.toml".hello = "world";
+ files.yaml."/generated/hello.yaml".hello = "world";
+ files.hcl."/generated/hello.hcl".hello = "world";
+ files.text."/generated/hello.txt" = "world";
+}
+
+
+Your file can be complemented with another module
+# examples/world.nix
+# almost same as previous example
+# but show some language feature
+let
+ name = "hello"; # a variable
+in
+{
+ files = {
+ json."/generated/${name}.json".baz = ["foo" "bar" name];
+ toml."/generated/${name}.toml".baz = ["foo" "bar" name];
+ yaml = {
+ "/generated/${name}.yaml" = {
+ baz = [
+ "foo"
+ "bar"
+ name
+ ];
+ };
+ };
+ };
+}
+
+
+Content generated by those examples are in generated
+# ie ./generated/hello.yaml
+baz:
+ - foo
+ - bar
+ - hello
+hello: world
+
+
+This project is configured by module project.nix
+# ./project.nix
+{
+ # import other modules
+ imports = [
+ ./examples/hello.nix
+ ./examples/world.nix
+ ./examples/readme.nix
+ ./examples/gitignore.nix
+ ./examples/license.nix
+ ./examples/docs.nix
+ ./examples/book.nix
+ ./examples/services.nix
+ ./examples/nim.nix
+ ./examples/nushell.nix
+ ./examples/watch.nix
+ ];
+
+ # install development or deployment tools
+ packages = [
+ "convco"
+ # now we can use 'convco' command https://convco.github.io
+
+ # but could be:
+ # "awscli"
+ # "azure-cli"
+ # "cargo"
+ # "conda"
+ # "go"
+ # "nim"
+ # "nodejs"
+ # "nodejs-18_x"
+ # "nushell"
+ # "pipenv"
+ # "python39"
+ # "ruby"
+ # "rustc"
+ # "terraform"
+ # "yarn"
+ # look at https://search.nixos.org for more packages
+ ];
+
+ # create alias
+ files.alias.feat = ''convco commit --feat $@'';
+ files.alias.fix = ''convco commit --fix $@'';
+ files.alias.docs = ''convco commit --docs $@'';
+ files.alias.alou = ''
+ #!/usr/bin/env python
+ print("Alo!") # is hello in portuguese
+ '';
+
+ # now we can use feat, fix, docs and alou commands
+
+ # create .envrc for direnv
+ files.direnv.enable = true;
+
+ # disabe file creation when entering in the shell
+ # call devshell-files instead
+ # files.on-call = true;
+}
+
+
+This README.md is also a module defined as above
+# There is a lot things we could use to write static file
+# Basic intro to nix language https://github.com/tazjin/nix-1p
+# Some nix functions https://teu5us.github.io/nix-lib.html
+{lib, ...}:
+{
+ files.text."/README.md" = builtins.concatStringsSep "\n" [
+ "# Devshell Files Maker"
+ (builtins.readFile ./readme/toc.md)
+ (builtins.readFile ./readme/about.md)
+ (builtins.readFile ./readme/installation.md)
+ (builtins.import ./readme/examples.nix)
+ ((builtins.import ./readme/modules.nix) lib)
+ (builtins.readFile ./readme/todo.md)
+ (builtins.readFile ./readme/issues.md)
+ (builtins.readFile ./readme/seeAlso.md)
+ ];
+}
+
+
+Our .gitignore is defined like this
+# ./examples/gitignore.nix
+{
+ # create my .gitignore copying ignore patterns from
+ # github.com/github/gitignore
+ files.gitignore.enable = true;
+ files.gitignore.template."Global/Archives" = true;
+ files.gitignore.template."Global/Backup" = true;
+ files.gitignore.template."Global/Diff" = true;
+ files.gitignore.pattern."**/.data" = true;
+ files.gitignore.pattern."**/.direnv" = true;
+ files.gitignore.pattern."**/.envrc" = true;
+ files.gitignore.pattern."**/.gitignore" = true;
+ files.gitignore.pattern."**/flake.lock" = true;
+}
+
+
+And our LICENSE file is
+# ./examples/license.nix
+{
+ # LICENSE file creation
+ # using templates from https://github.com/spdx/license-list-data
+ files.license.enable = true;
+ files.license.spdx.name = "MIT";
+ files.license.spdx.vars.year = "2023";
+ files.license.spdx.vars."copyright holders" = "Cruel Intentions";
+}
+
+
+
+ Helps static file/configuration creation with Nix and devshell.
+There is a bunch of ways static file/configuration are hard, this will help you generate, validate and distribute JSON, YAML, TOML or TXT.
+Your content will be defined in Nix Language, it means you can use variables, functions, imports, read files, etc.
+The modular system helps layering configurations, hiding complexity and making it easier for OPS teams.
+Your content modules could optionally be well defined and type checked in build proccess with this same tool.
+Or you could use Nix as package manager and install any tool to validate your configuration (ie integrating it with existing JSON Schema).
+Nix integrates well with git and http, it could be also used to read JSON, YAML, TOML, zip and gz files.
+In fact Nix isn't a configuration tool but a package manger, we are only using it as configuration tool because the language is simple and flexible.
+You can recreate files of a repository directly to your local machine by running nix develop <flake-uri> --build
, example:
# copy all my dogfood to your current folder
+nix develop github:cruel-intentions/devshell-files --build
+
+With help of Nix and devshell you could install any development or deployment tool of its 80 000 packages.
+ +