diff --git a/.editorconfig b/.editorconfig index f270d4cdaa8..e75c42879eb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,53 @@ -# EditorConfig: https://EditorConfig.org +# EditorConfig configuration for this repository -- https://EditorConfig.org +# Top-most EditorConfig file root = true +# Unix-style newlines with a newline ending every file, utf-8 charset [*] -indent_style = tab -tab_width = 8 -charset = utf-8 -insert_final_newline = true end_of_line = lf +insert_final_newline = true trim_trailing_whitespace = true +charset = utf-8 + +# Ignore diffs/patches +[*.{diff,patch}] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset -[*.sh] +# Prefer space-indent for.. +[*.{json,lock,md,pl,pm,py,rb,xml}] indent_style = space + +# Prefer tab-indent for.. +[*.{nix,sh,bash}] +indent_style = tab + +[*.{json,lock,md,nix,rb,sh}] indent_size = 2 + +[*.lock] +indent_size = unset + +[*.md] +trim_trailing_whitespace = true + +# binaries +[*.nib] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset +charset = unset + +[eggs.nix] +trim_trailing_whitespace = unset + +# You can add file-specific configuration using: +# +# [path/to/file] +# end_of_line = unset +# indent_style = unset +# insert_final_newline = unset +# trim_trailing_whitespace = unset +# other config.. diff --git a/.envrc b/.envrc new file mode 100644 index 00000000000..c2cb68fdc28 --- /dev/null +++ b/.envrc @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +# shellcheck shell=sh # POSIX + +# This file is used to provide directory-oriented environment variables and integrations + +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore index e813493526f..c9a29188b59 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ tarballs/ *~ *.kate-swp *.kdev4 + +# Direnv +.direnv/ diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 00000000000..f5018915d8a --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,19 @@ +shell=sh # Enforce POSIX sh + +# name: avoid-nullary-conditions +# desc: Suggest explicitly using -n in `[ $var ]` +# example: [ "$var" ] +# fix: [ -n "$var" ] +enable=avoid-nullary-conditions + +# name: check-extra-masked-returns +# desc: Check for additional cases where exit codes are masked +# example: rm -r "$(get_chroot_dir)/home" +# fix: set -e; dir="$(get_chroot_dir)"; rm -r "$dir/home" +enable=check-extra-masked-returns + +# name: check-set-e-suppressed +# desc: Notify when set -e is suppressed during function invocation +# example: set -e; func() { cp *.txt ~/backup; rm *.txt; }; func && echo ok +# fix: set -e; func() { cp *.txt ~/backup; rm *.txt; }; func; echo ok +enable=check-set-e-suppressed diff --git a/default.code-workspace b/default.code-workspace new file mode 100644 index 00000000000..c0d368b1703 --- /dev/null +++ b/default.code-workspace @@ -0,0 +1,134 @@ +{ + "folders": [ + { "path": "." }, + { "path": "vendor/impermanence" }, + ], + + "settings": { + // Enable liguratures + "editor.fontLigatures": true, + "editor.fontFamily": "'Fira Code'", + "terminal.integrated.fontFamily": "'Fira Code'", + + // FIXME(Krey): This should automatically use javacsript, fix this upstream + "files.associations": { + "*.es": "javascript" + }, + + "editor.renderWhitespace": "all", + "terminal.integrated.scrollback": 20000, + "nix.enableLanguageServer": true, + "nix.serverPath": "nil", + "nix.serverSettings": { + // settings for 'nil' Language Server + "nil": { + "formatting": { + "command": ["nixpkgs-fmt"] + } + } + }, + "bracket-pair-colorizer-2.excludedLanguages": [ + "nix" // Does weird and confusing coloring, seems not compatible + ], + "editor.wordWrap": "on", // Enforce word-wrapped coding style + "terminal.integrated.defaultProfile.linux": "bash", // Use bash by default + "terminal.integrated.env.linux": { + "EDITOR": "nano", // To open git things in codium + }, + + // Gtt + "git.autofetch": true, + + // Code-eol + "code-eol.highlightExtraWhitespace": true, + "code-eol.newlineCharacter": "↵", + "code-eol.crlfCharacter": "↓", + + // Task tree + "todo-tree.general.tags": [ + "FIXME", + "TODO", + "DOCS", + "HACK", + "REVIEW", + "DNM", // Do Not Merge + "DNC", // Do Not Contribute + "DNR" // Do Not Release + ], + // NOTE: Icons has to be valid octicon (https://primer.style/foundations/icons/) + "todo-tree.highlights.customHighlight": { + // FIXME(Krey): Test + "FIXME": { + "foreground": "#ff8000", + "icon": "tag", + "fontWeight": "bold" + }, + // TODO(Krey): Test + "TODO": { + "foreground": "#00ffea", + "icon": "tasklist", + "fontWeight": "bold" + }, + // DOCS(Krey): Test + "DOCS": { + "foreground": "#ffffff", + "background": "#2f00ff", + "icon": "repo", + "fontWeight": "bold" + }, + // HACK(Krey): Test + "HACK": { + "foreground": "#ffffff", + "background": "#ff4d00", + "icon": "repo", + "fontWeight": "bold" + }, + // REVIEW(Krey): Test + "REVIEW": { + "foreground": "#ffffff", + "background": "#b300ff", + "icon": "code-review", + "fontWeight": "bold" + }, + // DNM(Krey): Test + "DNM": { + "background": "#ff0000", + "foreground": "#ffffff", + "icon": "shield-x", + "fontWeight": "bold" + }, + // DNR(Krey): Test + "DNR": { + "background": "#ff0000", + "foreground": "#ffffff", + "icon": "shield-x", + "fontWeight": "bold" + }, + // DNC(Krey): Test + "DNC": { + "background": "#fffb00", + "foreground": "#000000", + "icon": "shield-x", + "fontWeight": "bold" + } + }, + "todo-tree.regex.regex": "($TAGS)((\\-.*|)\\(.*\\)):", // ($TAGS)((\\-.*|)\\(.*\\)): + }, + + "extensions": { + "recommendations": [ + "jnoortheen.nix-ide", + "oderwat.indent-rainbow", + "arrterian.nix-env-selector", + "medo64.render-crlf", + "aaron-bond.better-comments", + "mkhl.direnv", + "coenraads.bracket-pair-colorizer-2", + "editorconfig.editorconfig", + "pkief.material-icon-theme", + "markwylde.vscode-filesize", + "plorefice.devicetree", + "timonwong.shellcheck" + ] + } +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..2f9ed4b306f --- /dev/null +++ b/flake.lock @@ -0,0 +1,397 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732284644, + "narHash": "sha256-REGLarOB5McRMmFtOgNihEXXQILY6+2UBAY8lw8CJCI=", + "owner": "nix-community", + "repo": "disko", + "rev": "abc8baff333ac9dca930fc4921a26a8fc248e442", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "disko-master": { + "inputs": { + "nixpkgs": [ + "nixpkgs-master" + ] + }, + "locked": { + "lastModified": 1732284644, + "narHash": "sha256-REGLarOB5McRMmFtOgNihEXXQILY6+2UBAY8lw8CJCI=", + "owner": "nix-community", + "repo": "disko", + "rev": "abc8baff333ac9dca930fc4921a26a8fc248e442", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "disko-unstable": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1732284644, + "narHash": "sha256-REGLarOB5McRMmFtOgNihEXXQILY6+2UBAY8lw8CJCI=", + "owner": "nix-community", + "repo": "disko", + "rev": "abc8baff333ac9dca930fc4921a26a8fc248e442", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1730504689, + "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "506278e768c2a08bec68eb62932193e341f55c90", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1723604017, + "narHash": "sha256-rBtQ8gg+Dn4Sx/s+pvjdq3CB2wQNzx9XGFq/JVGCB6k=", + "owner": "srid", + "repo": "flake-root", + "rev": "b759a56851e10cb13f6b8e5698af7b59c44be26e", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, + "mission-control": { + "locked": { + "lastModified": 1727581548, + "narHash": "sha256-LDAHv2KECDaf9hf6oFV2dMCqPzEaYFcmeQCOnA+/eh8=", + "owner": "Platonic-Systems", + "repo": "mission-control", + "rev": "781a209a8cdeb9e63a26d19b2e3b75565266db97", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "mission-control", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1731805462, + "narHash": "sha256-yhEMW4MBi+IAyEJyiKbnFvY1uARyMKJpLUhkczI49wk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "b9f04e3cf71c23bea21d2768051e6b3068d44734", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixlib_2": { + "locked": { + "lastModified": 1731805462, + "narHash": "sha256-yhEMW4MBi+IAyEJyiKbnFvY1uARyMKJpLUhkczI49wk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "b9f04e3cf71c23bea21d2768051e6b3068d44734", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixlib_3": { + "locked": { + "lastModified": 1731805462, + "narHash": "sha256-yhEMW4MBi+IAyEJyiKbnFvY1uARyMKJpLUhkczI49wk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "b9f04e3cf71c23bea21d2768051e6b3068d44734", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-flake": { + "locked": { + "lastModified": 1729697921, + "narHash": "sha256-gqcmWE+4Vr5/l6AoQc2jIbJHCAXAY+qWPC0ruoAHV1Q=", + "owner": "srid", + "repo": "nixos-flake", + "rev": "e60e64841e74c777799624531dcb2f311f95f639", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "nixos-flake", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732151224, + "narHash": "sha256-5IgpueM8SGLOadzUJK6Gk37zEBXGd56BkNOtoWmnZos=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "3280fdde8c8f0276c9f5286ad5c0f433dfa5d56c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixos-generators-master": { + "inputs": { + "nixlib": "nixlib_2", + "nixpkgs": [ + "nixpkgs-master" + ] + }, + "locked": { + "lastModified": 1732151224, + "narHash": "sha256-5IgpueM8SGLOadzUJK6Gk37zEBXGd56BkNOtoWmnZos=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "3280fdde8c8f0276c9f5286ad5c0f433dfa5d56c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixos-generators-unstable": { + "inputs": { + "nixlib": "nixlib_3", + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1732151224, + "narHash": "sha256-5IgpueM8SGLOadzUJK6Gk37zEBXGd56BkNOtoWmnZos=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "3280fdde8c8f0276c9f5286ad5c0f433dfa5d56c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1731797254, + "narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=", + "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59", + "revCount": 636838, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2405.636838%2Brev-e8c38b73aeb218e27163376a2d617e61a2ad9b59/01933af8-1a6e-73c9-86e6-04b8a0066d59/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz" + } + }, + "nixpkgs-23_05": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-23_11": { + "locked": { + "lastModified": 1720535198, + "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-24_05": { + "locked": { + "lastModified": 1731797254, + "narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1730504152, + "narHash": "sha256-lXvH/vOfb4aGYyvFmZK/HlsNsr/0CVWlwYvo2rxJk3s=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/cc2f28000298e1269cea6612cd06ec9979dd5d7f.tar.gz" + } + }, + "nixpkgs-master": { + "locked": { + "lastModified": 1732339485, + "narHash": "sha256-2riYqt+9MGyv2W9d1yeYMkCPGI4Ed53iaf9jqXQY+HI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "83f7f0c21772c354975e4fcd11494ea84fe2e4ae", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-staging": { + "locked": { + "lastModified": 1732320902, + "narHash": "sha256-cOekwUlPJCScqv2EMJYIRO8a/St2v+qlnsaYNFvrwV0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5d73f1b15fb8dbba84a5794131599215d5f9c569", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "staging", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-staging-next": { + "locked": { + "lastModified": 1732320879, + "narHash": "sha256-EgYGZX6mLIT1vcS2z7HgTaWTrg4B4R4+f8t1G3Lrrug=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ae6f2c441777dce5d3ec167e6e89eb35145a75fb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "staging-next", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "disko-master": "disko-master", + "disko-unstable": "disko-unstable", + "flake-parts": "flake-parts", + "flake-root": "flake-root", + "mission-control": "mission-control", + "nixos-flake": "nixos-flake", + "nixos-generators": "nixos-generators", + "nixos-generators-master": "nixos-generators-master", + "nixos-generators-unstable": "nixos-generators-unstable", + "nixpkgs": "nixpkgs", + "nixpkgs-23_05": "nixpkgs-23_05", + "nixpkgs-23_11": "nixpkgs-23_11", + "nixpkgs-24_05": "nixpkgs-24_05", + "nixpkgs-master": "nixpkgs-master", + "nixpkgs-staging": "nixpkgs-staging", + "nixpkgs-staging-next": "nixpkgs-staging-next", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..e37dafa3a64 --- /dev/null +++ b/flake.nix @@ -0,0 +1,117 @@ +{ + description = "NiXium's Coreboot"; + + inputs = { + # Release inputs + nixpkgs-master.url = "github:nixos/nixpkgs/master"; + nixpkgs-staging-next.url = "github:nixos/nixpkgs/staging-next"; + nixpkgs-staging.url = "github:nixos/nixpkgs/staging"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz"; + + nixpkgs-23_05.url = "github:nixos/nixpkgs/nixos-23.05"; + nixpkgs-23_11.url = "github:nixos/nixpkgs/nixos-23.11"; + nixpkgs-24_05.url = "github:nixos/nixpkgs/nixos-24.05"; + + # Principle inputs + nixos-flake.url = "github:srid/nixos-flake"; + flake-parts.url = "github:hercules-ci/flake-parts"; + mission-control.url = "github:Platonic-Systems/mission-control"; + + flake-root.url = "github:srid/flake-root"; + + # DISKO + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + disko-unstable = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + disko-master = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs-master"; + }; + + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixos-generators-unstable = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + nixos-generators-master = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs-master"; + }; + }; + + outputs = inputs @ { self, ... }: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + # ./lib # Implement libs + # ./tasks # Include Tasks + + inputs.flake-root.flakeModule + inputs.mission-control.flakeModule + ]; + + # Set Supported Systems + systems = [ + "x86_64-linux" + "aarch64-linux" + "riscv64-linux" + "armv7l-linux" + ]; + + perSystem = { system, config, inputs', ... }: { + devShells.default = inputs.nixpkgs.legacyPackages.${system}.mkShell { + name = "Coreboot-devshell"; + nativeBuildInputs = [ + # Shell + inputs.nixpkgs.legacyPackages.${system}.bashInteractive # For terminal + inputs.nixpkgs.legacyPackages.${system}.shellcheck # Linting of shell files + + # Nix + inputs.nixpkgs.legacyPackages.${system}.nil # Needed for linting + inputs.nixpkgs.legacyPackages.${system}.nixpkgs-fmt # Nixpkgs formatter + + # Utilities + inputs.nixpkgs.legacyPackages.${system}.git # Working with the codebase + inputs.nixpkgs.legacyPackages.${system}.nano # Editor to work with the codebase in cli + + inputs.nixos-generators.packages.${system}.nixos-generate + + inputs.nixpkgs.legacyPackages.${system}.fira-code # For liquratures in code editors + + inputs.disko.packages.${system}.disko-install + inputs.disko.packages.${system}.disko + + # Build Dependencies + inputs.nixpkgs.legacyPackages.${system}.ncurses + inputs.nixpkgs.legacyPackages.${system}.pkg-config + inputs.nixpkgs.legacyPackages.${system}.openssl + inputs.nixpkgs.legacyPackages.${system}.coreboot-toolchain.i386 + inputs.nixpkgs.legacyPackages.${system}.libuuid + inputs.nixpkgs.legacyPackages.${system}.imagemagick + inputs.nixpkgs.legacyPackages.${system}.python312 + inputs.nixpkgs.legacyPackages.${system}.python312Packages.pyopenssl + inputs.nixpkgs.legacyPackages.${system}.m4 + inputs.nixpkgs.legacyPackages.${system}.bison + inputs.nixpkgs.legacyPackages.${system}.flex + ]; + inputsFrom = [ + config.mission-control.devShell + config.flake-root.devShell + ]; + # Environmental Variables + #VARIABLE = "value"; # Comment + }; + + formatter = inputs.nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + }; + }; +}