diff --git a/README.md b/README.md index 77529e94b..e13623994 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,17 @@ Neorg's setup process is slightly more complex than average, so we encourage you installation process, run `:checkhealth neorg` to see if everything's correct!** +### nix one-liner + +If you have [nix](https://nixos.org/) with [flakes](https://nixos.wiki/wiki/Flakes) enabled, you can try neorg in one line: + +`nix run 'github:nvim-neorg/neorg?dir=flake-app'` + +It opens a self-contained neorg bundled with xterm, fonts, colorscheme and other basic configurations, +so that you can try neorg with zero hassle. + +It opens the default neorg workspace under `~/neorg-notes`. Copy and modify `flake-app/flake.nix` if you want to change the path. + ### `neorg-kickstart` Not bothered to set up Neovim on your own? Check out our [kickstart config](https://github.com/nvim-neorg/neorg/wiki/Kickstart) diff --git a/flake-app/flake.lock b/flake-app/flake.lock new file mode 100644 index 000000000..223b718c2 --- /dev/null +++ b/flake-app/flake.lock @@ -0,0 +1,241 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "kanagawa": { + "flake": false, + "locked": { + "lastModified": 1760519540, + "narHash": "sha256-nHcQWTX4x4ala6+fvh4EWRVcZMNk5jZiZAwWhw03ExE=", + "owner": "rebelot", + "repo": "kanagawa.nvim", + "rev": "aef7f5cec0a40dbe7f3304214850c472e2264b10", + "type": "github" + }, + "original": { + "owner": "rebelot", + "repo": "kanagawa.nvim", + "rev": "aef7f5cec0a40dbe7f3304214850c472e2264b10", + "type": "github" + } + }, + "lua-utils": { + "flake": false, + "locked": { + "lastModified": 1708177208, + "narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=", + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "ref": "v1.0.2", + "repo": "lua-utils.nvim", + "type": "github" + } + }, + "neorg": { + "flake": false, + "locked": { + "lastModified": 1768058837, + "narHash": "sha256-azweiMPwFywBXZeIdaLDlqU9ey8/3TciphnxA24ehXQ=", + "owner": "nvim-neorg", + "repo": "neorg", + "rev": "408fc04013a95da8f217cb0958a06b6a77c01743", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "ref": "v9.4.0", + "repo": "neorg", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1772598333, + "narHash": "sha256-YaHht/C35INEX3DeJQNWjNaTcPjYmBwwjFJ2jdtr+5U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fabb8c9deee281e50b1065002c9828f2cf7b2239", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1772328832, + "narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nui": { + "flake": false, + "locked": { + "lastModified": 1708114759, + "narHash": "sha256-L0ebXtv794357HOAgT17xlEJsmpqIHGqGlYfDB20WTo=", + "owner": "MunifTanjim", + "repo": "nui.nvim", + "rev": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733", + "type": "github" + }, + "original": { + "owner": "MunifTanjim", + "ref": "0.3.0", + "repo": "nui.nvim", + "type": "github" + } + }, + "nvim-nio": { + "flake": false, + "locked": { + "lastModified": 1737405073, + "narHash": "sha256-eDbzJAGdUBhTwuD0Nt9FihZj1MmVdQfn/GKIybuu5a8=", + "owner": "nvim-neotest", + "repo": "nvim-nio", + "rev": "21f5324bfac14e22ba26553caf69ec76ae8a7662", + "type": "github" + }, + "original": { + "owner": "nvim-neotest", + "ref": "v1.10.1", + "repo": "nvim-nio", + "type": "github" + } + }, + "nvim-treesitter": { + "flake": false, + "locked": { + "lastModified": 1729666409, + "narHash": "sha256-8MQWi9FmcsD+p3c9neaoocnoDpNOskRvUPXAf+iJZDs=", + "owner": "nvim-treesitter", + "repo": "nvim-treesitter", + "rev": "cfc6f2c117aaaa82f19bcce44deec2c194d900ab", + "type": "github" + }, + "original": { + "owner": "nvim-treesitter", + "ref": "v0.9.3", + "repo": "nvim-treesitter", + "type": "github" + } + }, + "pathlib": { + "flake": false, + "locked": { + "lastModified": 1724943804, + "narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=", + "owner": "pysan3", + "repo": "pathlib.nvim", + "rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1", + "type": "github" + }, + "original": { + "owner": "pysan3", + "ref": "v2.2.3", + "repo": "pathlib.nvim", + "type": "github" + } + }, + "plenary": { + "flake": false, + "locked": { + "lastModified": 1697031827, + "narHash": "sha256-zR44d9MowLG1lIbvrRaFTpO/HXKKrO6lbtZfvvTdx+o=", + "owner": "nvim-lua", + "repo": "plenary.nvim", + "rev": "50012918b2fc8357b87cff2a7f7f0446e47da174", + "type": "github" + }, + "original": { + "owner": "nvim-lua", + "ref": "v0.1.4", + "repo": "plenary.nvim", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "kanagawa": "kanagawa", + "lua-utils": "lua-utils", + "neorg": "neorg", + "nixpkgs": "nixpkgs", + "nui": "nui", + "nvim-nio": "nvim-nio", + "nvim-treesitter": "nvim-treesitter", + "pathlib": "pathlib", + "plenary": "plenary", + "tree-sitter-norg": "tree-sitter-norg", + "tree-sitter-norg-meta": "tree-sitter-norg-meta" + } + }, + "tree-sitter-norg": { + "flake": false, + "locked": { + "lastModified": 1725461847, + "narHash": "sha256-z3h5qMuNKnpQgV62xZ02F5vWEq4VEnm5lxwEnIFu+Rw=", + "owner": "nvim-neorg", + "repo": "tree-sitter-norg", + "rev": "d89d95af13d409f30a6c7676387bde311ec4a2c8", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "ref": "v0.2.6", + "repo": "tree-sitter-norg", + "type": "github" + } + }, + "tree-sitter-norg-meta": { + "flake": false, + "locked": { + "lastModified": 1713028366, + "narHash": "sha256-8qSdwHlfnjFuQF4zNdLtU2/tzDRhDZbo9K54Xxgn5+8=", + "owner": "nvim-neorg", + "repo": "tree-sitter-norg-meta", + "rev": "6f0510cc516a3af3396a682fbd6655486c2c9d2d", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "ref": "v0.1.0", + "repo": "tree-sitter-norg-meta", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake-app/flake.nix b/flake-app/flake.nix new file mode 100644 index 000000000..bd68f9cba --- /dev/null +++ b/flake-app/flake.nix @@ -0,0 +1,159 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + flake-parts.url = "github:hercules-ci/flake-parts"; + + neorg = { + url = "github:nvim-neorg/neorg/v9.4.0"; + flake = false; + }; + + lua-utils = { + url = "github:nvim-neorg/lua-utils.nvim/v1.0.2"; + flake = false; + }; + + nvim-treesitter = { + url = "github:nvim-treesitter/nvim-treesitter/v0.9.3"; + flake = false; + }; + + pathlib = { + url = "github:pysan3/pathlib.nvim/v2.2.3"; + flake = false; + }; + + nvim-nio = { + url = "github:nvim-neotest/nvim-nio/v1.10.1"; + flake = false; + }; + + nui = { + url = "github:MunifTanjim/nui.nvim/0.3.0"; + flake = false; + }; + + plenary = { + url = "github:nvim-lua/plenary.nvim/v0.1.4"; + flake = false; + }; + + kanagawa = { + url = "github:rebelot/kanagawa.nvim/aef7f5cec0a40dbe7f3304214850c472e2264b10"; + flake = false; + }; + + tree-sitter-norg = { + url = "github:nvim-neorg/tree-sitter-norg/v0.2.6"; + flake = false; + }; + + tree-sitter-norg-meta = { + url = "github:nvim-neorg/tree-sitter-norg-meta/v0.1.0"; + flake = false; + }; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" ]; + + # Per-system attributes (packages, devShells) + perSystem = { config, self', inputs', pkgs, system, ... }: let + tsNorg = pkgs.stdenv.mkDerivation { + name = "tree-sitter-norg"; + src = inputs.tree-sitter-norg; + buildPhase = '' + ${pkgs.gcc}/bin/gcc -c -fPIC -O2 -I src src/parser.c -o parser.o + ${pkgs.gcc}/bin/g++ -c -fPIC -O2 -I src src/scanner.cc -std=c++14 -o scanner.o + ${pkgs.gcc}/bin/g++ -shared -o parser.so parser.o scanner.o + ''; + installPhase = '' + mkdir -p $out/parser + cp parser.so $out/parser/norg.so + ''; + }; + tsNorgMeta = pkgs.stdenv.mkDerivation { + name = "tree-sitter-norg-meta"; + src = inputs.tree-sitter-norg-meta; + buildPhase = '' + ${pkgs.gcc}/bin/gcc -shared -fPIC -O2 -I src -o parser.so src/parser.c + ''; + installPhase = '' + mkdir -p $out/parser + cp parser.so $out/parser/norg_meta.so + ''; + }; + parsers = pkgs.symlinkJoin { + name = "ts-parsers"; + paths = [ tsNorg tsNorgMeta ]; + }; + + nerdFonts = pkgs.nerd-fonts.meslo-lg; + fontConf = pkgs.makeFontsConf { fontDirectories = [ nerdFonts ]; }; + + mainNotesPath = "~/neorg-notes"; + nvimInitLua = '' + vim.opt.runtimepath:append('${inputs.nvim-nio}') + vim.opt.runtimepath:append('${inputs.lua-utils}') + vim.opt.runtimepath:append('${inputs.plenary}') + vim.opt.runtimepath:append('${inputs.nui}') + vim.opt.runtimepath:append('${inputs.pathlib}') + vim.opt.runtimepath:append('${inputs.nvim-treesitter}') + vim.opt.runtimepath:append('${inputs.neorg}') + vim.opt.runtimepath:append('${inputs.kanagawa}') + vim.opt.runtimepath:append('${parsers}') + + require("nvim-treesitter.configs").setup { + highlight = { enable = true }, + } + + require('neorg').setup { + load = { + ["core.defaults"] = {}, + ["core.integrations.treesitter"] = { + config = { + configure_parsers = true, + install_parsers = false, -- Since we provide them manually + }, + }, + + ["core.concealer"] = {}, + ["core.dirman"] = { + config = { + workspaces = { + notes = "${mainNotesPath}", + }, + default_workspace = "notes", + }, + }, + }, + } + + vim.wo.foldlevel = 99 + vim.wo.conceallevel = 2 + vim.cmd.colorscheme "kanagawa" + ''; + nvimInitLuaFile = pkgs.writeText "init.lua" nvimInitLua; + in { + packages.default = pkgs.writeShellScriptBin "neorg" '' + export FONTCONFIG_FILE=${fontConf} + + args=( + "${pkgs.xterm}/bin/xterm" + -bg black -fg white # force dark theme + -xrm 'XTerm.omitTranslation: fullscreen' # unbind alt+return keybind from xterm + -fa 'MesloLGL Nerd Font Mono:style=Regular:size=12' # config nerd font + -fs 12 # font size + -e "${pkgs.neovim}/bin/nvim" + -u "${nvimInitLuaFile}" + -c 'Neorg index' # start neorg index upfront + ) + + exec "''${args[@]}" + ''; + }; + }; +}