From e7d3723315df3aba404891ec219a2690618d0232 Mon Sep 17 00:00:00 2001 From: Marcel <34819524+MarcelCoding@users.noreply.github.com> Date: Sun, 30 Jun 2024 01:46:22 +0200 Subject: [PATCH] demo: init (#15) Co-authored-by: Sandro --- .github/workflows/gh-pages.yaml | 47 ++++ demo/flake.lock | 409 ++++++++++++++++++++++++++++++++ demo/flake.nix | 57 +++++ flake.lock | 6 +- nix/fixup-options.py | 32 +-- 5 files changed, 532 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/gh-pages.yaml create mode 100644 demo/flake.lock create mode 100644 demo/flake.nix diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml new file mode 100644 index 0000000..8d2ef1b --- /dev/null +++ b/.github/workflows/gh-pages.yaml @@ -0,0 +1,47 @@ +name: "pages" +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +permissions: + actions: read + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + name: Build search + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@V27 + + - name: Build search + working-directory: demo + run: nix build -L --override-input search .. + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: demo/result + + deploy: + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + if: github.event_name == 'push' diff --git a/demo/flake.lock b/demo/flake.lock new file mode 100644 index 0000000..525dd9c --- /dev/null +++ b/demo/flake.lock @@ -0,0 +1,409 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "owner": "numtide", + "repo": "devshell", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719259945, + "narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719588253, + "narHash": "sha256-A03i8xiVgP14DCmV5P7VUv37eodCjY4e1iai0b2EuuM=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "7e68e55d2e16d3a1e92a679430728c35a30fd24e", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719128254, + "narHash": "sha256-I7jMpq0CAOZA/i70+HDQO/ulLttyQu/K70cSESiMX7A=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "50581970f37f06a4719001735828519925ef8310", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixos-modules": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "search": "search" + }, + "locked": { + "lastModified": 1719615856, + "narHash": "sha256-MEMUsSLfzhMTGmYMGj4G3yQK7Gh4FVwb62oJFRZysjM=", + "owner": "nuschtos", + "repo": "nixos-modules", + "rev": "ee8686daa5510d79e6d8134d56a9e477bcb5e3ce", + "type": "github" + }, + "original": { + "owner": "nuschtos", + "repo": "nixos-modules", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719506693, + "narHash": "sha256-C8e9S7RzshSdHB7L+v9I51af1gDM5unhJ2xO1ywxNH8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b2852eb9365c6de48ffb0dc2c9562591f652242a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks": "git-hooks", + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1719695745, + "narHash": "sha256-4i71R8xofnwmlhb84swOLQro63pHvC37NVIipbz1I04=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "c062b976eff9f13597c7c23d77a6b3ac677b7fd5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixos-modules": "nixos-modules", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim", + "search": "search_2" + } + }, + "search": { + "inputs": { + "flake-utils": [ + "nixos-modules", + "flake-utils" + ], + "nixpkgs": [ + "nixos-modules", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719609822, + "narHash": "sha256-zc6zlMx/x/LFTAbipkDBsWBE99SX1HDqry1Bxi5Sqqg=", + "owner": "nuschtos", + "repo": "search", + "rev": "4e13cf6dbd5d1f193a852af35f2f684eb538c8b8", + "type": "github" + }, + "original": { + "owner": "nuschtos", + "repo": "search", + "type": "github" + } + }, + "search_2": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 0, + "narHash": "sha256-LncZXiCmV8yd0TPqI/p/kSNsF8FG4BKRfAuiHTWBAoA=", + "path": "../.", + "type": "path" + }, + "original": { + "path": "../.", + "type": "path" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719243788, + "narHash": "sha256-9T9mSY35EZSM1KAwb7K9zwQ78qTlLjosZgtUGnw4rn4=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "065a23edceff48f948816b795ea8cc6c0dee7cdf", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/demo/flake.nix b/demo/flake.nix new file mode 100644 index 0000000..1379a80 --- /dev/null +++ b/demo/flake.nix @@ -0,0 +1,57 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + search = { + # use --override-input search .. + url = "path:../."; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + nixos-modules = { + url = "github:nuschtos/nixos-modules"; + inputs = { + nixpkgs.follows = "nixpkgs"; + search.follows = "search"; + }; + }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, flake-utils, search, nixos-modules, nixvim, ... }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; + in + { + packages = { + default = search.packages.${system}.mkMultiSearch [ + { + modules = [ + ({ config, lib, ... }: { + _module.args = { + libS = nixos-modules.lib { inherit config lib; }; + inherit pkgs; + }; + }) + nixos-modules.nixosModule + ]; + urlPrefix = "https://github.com/NuschtOS/nixos-modules/tree/main/"; + } + { + optionsJSON = nixvim.packages.${system}.options-json + /share/doc/nixos/options.json; + optionsPrefix = "programs.nixvim"; + urlPrefix = "https://github.com/nix-community/nixvim/tree/main/"; + } + ]; + }; + }); +} diff --git a/flake.lock b/flake.lock index 0005e7e..dabb6a0 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719254875, - "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", + "lastModified": 1719506693, + "narHash": "sha256-C8e9S7RzshSdHB7L+v9I51af1gDM5unhJ2xO1ywxNH8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60", + "rev": "b2852eb9365c6de48ffb0dc2c9562591f652242a", "type": "github" }, "original": { diff --git a/nix/fixup-options.py b/nix/fixup-options.py index 9158e41..d3efafe 100644 --- a/nix/fixup-options.py +++ b/nix/fixup-options.py @@ -31,22 +31,22 @@ def update_declaration(url, declaration): out = [] for i in range(1,len(sys.argv),2): - file = open(sys.argv[i]) - url = sys.argv[i+1] - data = json.load(file) - - for key in data: - entry = data[key] - entry["name"] = key - del entry["loc"] - entry["declarations"] = list(map(lambda x: update_declaration(url, x), entry["declarations"])) - - entry["description"] = markdown.markdown(entry["description"]) - if 'default' in entry: - entry['default'] = code(entry["default"]) - if 'example' in entry: - entry['example'] = code(entry["example"]) - out.append(entry) + with open(sys.argv[i], "r", encoding="utf-8") as file: + url = sys.argv[i+1] + data = json.load(file) + + for key in data: + entry = data[key] + entry["name"] = key + del entry["loc"] + entry["declarations"] = list(map(lambda x: update_declaration(url, x), entry["declarations"])) + + entry["description"] = markdown.markdown(entry["description"]) + if 'default' in entry: + entry['default'] = code(entry["default"]) + if 'example' in entry: + entry['example'] = code(entry["example"]) + out.append(entry) print(json.dumps(out))