Init
This commit is contained in:
4
.dir-locals.el
Normal file
4
.dir-locals.el
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
((nil . ((projectile-project-project-file . "nim_org_parse.nimble")
|
||||||
|
(projectile-project-name . "Nim Org Parser")
|
||||||
|
(projectile-project-type . nim)
|
||||||
|
(projectile-test-prefix . "test_"))))
|
||||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
result
|
||||||
|
.nimble/
|
||||||
|
.direnv/
|
||||||
|
/dst/
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Florian Schrödl
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
5
README.org
Normal file
5
README.org
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#+TITLE: Readme
|
||||||
|
|
||||||
|
A simple [[https://orgmode.org/][org]] document parser.
|
||||||
|
|
||||||
|
This is not a full-fledged parser and only updated/fitted to my personal needs.
|
||||||
90
flake.lock
generated
Normal file
90
flake.lock
generated
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1642700792,
|
||||||
|
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nimble": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1622481822,
|
||||||
|
"narHash": "sha256-Cc7WmnQ1GQSdhlRunmxlGBSNikgiNpxWjs60Mvgg2Ps=",
|
||||||
|
"owner": "floscr",
|
||||||
|
"repo": "flake-nimble",
|
||||||
|
"rev": "7892251d6d0e5c6380e5fb04d8d79249b9e340c9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "floscr",
|
||||||
|
"repo": "flake-nimble",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixos": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1641528457,
|
||||||
|
"narHash": "sha256-FyU9E63n1W7Ql4pMnhW2/rO9OftWZ37pLppn/c1aisY=",
|
||||||
|
"path": "/nix/store/pwz0d92vl5hjrvhiri3qzazxjnf1r8wy-source",
|
||||||
|
"rev": "ff377a78794d412a35245e05428c8f95fef3951f",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixos",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1619945546,
|
||||||
|
"narHash": "sha256-jDQB+5iGBS0AqtT060yzQLixwNBcxNn4EOuu1bK6Pcw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c576998594b4b8790f291d17fa92d499d1dc5d42",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1642970779,
|
||||||
|
"narHash": "sha256-wccCiIecPkPE6wpidSRe9XEdJ6uCrNLmRtuhNwt1Kuk=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "a3d847c3bd3a3b75b3057d7b3730d3308dd8fd59",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nimble": "nimble",
|
||||||
|
"nixos": "nixos",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
69
flake.nix
Normal file
69
flake.nix
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
description = "A simple [[https://orgmode.org/][org]] document parser";
|
||||||
|
|
||||||
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
|
inputs.nimble.url = "github:floscr/flake-nimble";
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ self
|
||||||
|
, nixpkgs
|
||||||
|
, nimble
|
||||||
|
, nixos
|
||||||
|
, flake-utils
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
nimpkgs = nimble.packages.${system};
|
||||||
|
customNimPkgs = import ./nix/packages/nimExtraPackages.nix { inherit pkgs; inherit nimpkgs; };
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [ ];
|
||||||
|
utils = import ./nix/lib/nimBuildGenerator.nix;
|
||||||
|
inherit (nixos.lib) flatten;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
packages.nim_org_parse =
|
||||||
|
let
|
||||||
|
pkgName = "nim_org_parse";
|
||||||
|
in
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
name = pkgName;
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
nim
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = buildInputs;
|
||||||
|
|
||||||
|
buildPhase = utils.makeNimBuildScript {
|
||||||
|
srcFile = "./src/${pkgName}.nim";
|
||||||
|
dstName = pkgName;
|
||||||
|
packages = flatten [
|
||||||
|
(with nimpkgs; [
|
||||||
|
])
|
||||||
|
customNimPkgs.fusion
|
||||||
|
customNimPkgs.nimfp
|
||||||
|
];
|
||||||
|
extraLines = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
install -Dt \
|
||||||
|
$out/bin \
|
||||||
|
$TMPDIR/${pkgName}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
devShell = import ./shell.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
inherit nimpkgs;
|
||||||
|
inherit buildInputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultPackage = packages.nim_org_parse;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
22
nim_org_parse.nimble
Normal file
22
nim_org_parse.nimble
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Florian Schroedl"
|
||||||
|
description = "A simple [[https://orgmode.org/][org]] document parser"
|
||||||
|
license = "MIT"
|
||||||
|
srcDir = "src"
|
||||||
|
bin = @["nim_org_parse"]
|
||||||
|
binDir = "./dst"
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
requires "nim >= 1.4.4"
|
||||||
|
requires "https://github.com/floscr/nimfp#master"
|
||||||
|
requires "fusion"
|
||||||
|
# requires "print"
|
||||||
|
# requires "zero_functional"
|
||||||
|
# requires "cascade"
|
||||||
|
|
||||||
|
import distros
|
||||||
|
if detectOs(NixOS):
|
||||||
|
foreignDep "pkgconfig"
|
||||||
30
nix/lib/nimBuildGenerator.nix
Normal file
30
nix/lib/nimBuildGenerator.nix
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
let
|
||||||
|
inherit (builtins) foldl';
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
makeNimBuildScript =
|
||||||
|
{ srcFile
|
||||||
|
, dstName
|
||||||
|
, packages ? [ ]
|
||||||
|
, extraLines ? [ ]
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
packageLines = map (a: "-p:${a}/src") packages;
|
||||||
|
lines = [
|
||||||
|
"nim compile"
|
||||||
|
"-d:release"
|
||||||
|
"--hint[Processing]:off"
|
||||||
|
"--excessiveStackTrace:on"
|
||||||
|
] ++ packageLines
|
||||||
|
++ extraLines
|
||||||
|
++ [
|
||||||
|
"--out:$TMPDIR/${dstName}"
|
||||||
|
srcFile
|
||||||
|
];
|
||||||
|
buildCommand = foldl' (a: b: a + " " + b) "" lines;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
HOME=$TMPDIR
|
||||||
|
${buildCommand}
|
||||||
|
'';
|
||||||
|
}
|
||||||
24
nix/packages/nimExtraPackages.nix
Normal file
24
nix/packages/nimExtraPackages.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{ pkgs, nimpkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs;
|
||||||
|
{
|
||||||
|
fusion =
|
||||||
|
(fetchFromGitHub
|
||||||
|
({
|
||||||
|
owner = "nim-lang";
|
||||||
|
repo = "fusion";
|
||||||
|
rev = "v1.1";
|
||||||
|
sha256 = "9tn0NTXHhlpoefmlsSkoNZlCjGE8JB3eXtYcm/9Mr0I=";
|
||||||
|
}));
|
||||||
|
nimfp = with nimpkgs; [
|
||||||
|
(pkgs.fetchFromGitHub
|
||||||
|
({
|
||||||
|
owner = "floscr";
|
||||||
|
repo = "nimfp";
|
||||||
|
rev = "master";
|
||||||
|
sha256 = "sha256-gEs4qovho5qTXCquEG+fZOsL3rGB+Ql/r0IeLhnHjFk=";
|
||||||
|
}))
|
||||||
|
classy
|
||||||
|
nimboost
|
||||||
|
];
|
||||||
|
}
|
||||||
16
shell.nix
Normal file
16
shell.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ pkgs, nimpkgs, buildInputs }:
|
||||||
|
|
||||||
|
pkgs.mkShell {
|
||||||
|
shellHook = ''
|
||||||
|
export NIMBLE_DIR="$PWD/.nimble"
|
||||||
|
export NIMBLE_BIN_DIR="$NIMBLE_DIR/bin"
|
||||||
|
export PATH="$NIMBLE_BIN_DIR:$PATH"
|
||||||
|
# Mutable nimble install
|
||||||
|
[[ ! -f "$NIMBLE_BIN_DIR" ]] && nimble install
|
||||||
|
[[ ! -f "$NIMBLE_BIN_DIR/inim" ]] && nimble --accept install inim
|
||||||
|
'';
|
||||||
|
buildInputs = with pkgs; buildInputs ++ [
|
||||||
|
nim
|
||||||
|
nimlsp
|
||||||
|
];
|
||||||
|
}
|
||||||
1
src/nim_org_parse.nim
Normal file
1
src/nim_org_parse.nim
Normal file
@@ -0,0 +1 @@
|
|||||||
|
echo "Hello World"
|
||||||
Reference in New Issue
Block a user