This commit is contained in:
Patrick Neff 2024-09-12 22:22:26 +02:00
parent 5a4b306097
commit 14b2b85b0b
31 changed files with 8954 additions and 485 deletions

8413
flake.lock

File diff suppressed because it is too large Load Diff

139
flake.nix
View File

@ -1,12 +1,13 @@
{
description = "My Nix Configs";
outputs = {
self,
nixpkgs,
flake-utils,
...
}: let
outputs =
{ self
, nixpkgs
, flake-utils
, ...
}:
let
inherit (self) inputs outputs;
flakeLib = import ./lib;
@ -32,30 +33,9 @@
};
};
};
overlays = [
inputs.nixvim.overlays.default
inputs.nur.overlay
inputs.nixgl.overlay
outputs.overlays.kodi
];
overlays = import ./overlays { inherit inputs; };
in
{
overlays = {
kodi = final: prev: {
kodi-standalone =
final.kodi-wayland.withPackages
(kodiPkgs:
with kodiPkgs; [
youtube
pvr-iptvsimple
keymap
inputstream-adaptive
inputstream-ffmpegdirect
requests-cache
inputstreamhelper
]);
};
};
nixosModules = {
base = import ./modules/nixos/base;
desktop = import ./modules/nixos/desktop;
@ -66,7 +46,8 @@
server = import ./modules/nixos/server;
};
nixosConfigurations =
flakeLib.mkNixosConfiguration {
flakeLib.mkNixosConfiguration
{
inherit inputs nixpkgs outputs vars flakeLib overlays;
system = "x86_64-linux";
hostName = "vm";
@ -98,7 +79,8 @@
binary-cache = import ./modules/home-manager/binary-cache;
};
homeConfigurations =
flakeLib.mkHomeConfiguration {
flakeLib.mkHomeConfiguration
{
inherit inputs outputs nixpkgs flakeLib overlays;
vars = vars // { hostName = "wanaheim"; };
system = "x86_64-linux";
@ -118,16 +100,24 @@
};
system = "x86_64-linux";
};
templates = {
empty = {
path = ./templates/empty;
};
go = {
path = ./templates/go;
};
};
}
// flake-utils.lib.eachDefaultSystem (system: {
packages = {
neovim-ide = import ./pkgs/nixvim {inherit inputs system flakeLib nixpkgs vars;};
neovim-ide = import ./pkgs/nixvim { inherit inputs system flakeLib nixpkgs vars overlays; };
};
});
inputs = {
# System
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treesitter-grammars.url = "github:viperML/tree-sitter";
nur.url = "github:nix-community/NUR";
nix-colors.url = "github:misterio77/nix-colors";
systems.url = "github:nix-systems/default";
@ -137,18 +127,6 @@
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
@ -157,6 +135,72 @@
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
};
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";
};
# Neovim
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nvim-spell-de-utf8-dictionary = {
url = "http://ftp.vim.org/vim/runtime/spell/de.utf-8.spl";
flake = false;
};
nvim-spell-de-utf8-suggestions = {
url = "http://ftp.vim.org/vim/runtime/spell/de.utf-8.sug";
flake = false;
};
nvim-spell-de-latin1-dictionary = {
url = "http://ftp.vim.org/vim/runtime/spell/de.latin1.spl";
flake = false;
};
nvim-spell-de-latin1-suggestions = {
url = "http://ftp.vim.org/vim/runtime/spell/de.latin1.sug";
flake = false;
};
guihua = {
url = "github:ray-x/guihua.lua";
flake = false;
};
/*
neorg-overlay = {
url = "github:nvim-neorg/nixpkgs-neorg-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
*/
treesitter-grammars = {
url = "github:ratson/nix-treesitter";
inputs.flakelight.follows = "flakelight";
};
norg.url = "github:nvim-neorg/tree-sitter-norg/dev";
norg-meta.url = "github:nvim-neorg/tree-sitter-norg-meta";
neorg = {
url = "github:nvim-neorg/neorg";
flake = false;
};
neorg-telescope = {
url = "github:nvim-neorg/neorg-telescope";
flake = false;
};
# Misc
csleeptimer = {
url = "git+ssh://gitea@git.niederkassel.neff-steindesign.de/odie/csleeptimer.git";
inputs = {
@ -165,12 +209,5 @@
systems.follows = "systems";
};
};
neorg-overlay = {
url = "github:nvim-neorg/nixpkgs-neorg-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
}

View File

@ -1,12 +1,13 @@
_: {
{lib, ...}: {
imports = [
./gitea
./neovim-ide
./ghidra
];
programs = {
lazygit.enable = true;
gitea-cli.enable = true;
neovim-ide.enable = true;
lazygit.enable = lib.mkDefault true;
gitea-cli.enable = lib.mkDefault true;
neovim-ide.enable = lib.mkDefault true;
};
}

View File

@ -0,0 +1,11 @@
{ pkgs, lib, config, ... }:
{
options = {
programs.ghidra.enable = lib.mkEnableOption "ghidra";
};
config = lib.mkIf config.programs.ghidra.enable {
home.packages = [
pkgs.ghidra
];
};
}

View File

@ -1,16 +1,28 @@
{ outputs
, inputs
, pkgs
, config
, lib
, ...
}:
{
outputs,
pkgs,
config,
lib,
...
}: {
options = {
programs.neovim-ide.enable = lib.mkEnableOption "neovim-ide";
};
config = lib.mkIf config.programs.neovim-ide.enable {
home = {
packages = [ outputs.packages.${pkgs.system}.neovim-ide ];
sessionPath = [
"/home/odie/go/bin"
];
file = {
"${config.xdg.configHome}/nvim/spell/de.utf-8.spl".source = inputs.nvim-spell-de-utf8-dictionary;
"${config.xdg.configHome}/nvim/spell/de.utf-8.sug".source = inputs.nvim-spell-de-utf8-suggestions;
"${config.xdg.configHome}/nvim/spell/de.latin1.spl".source = inputs.nvim-spell-de-latin1-dictionary;
"${config.xdg.configHome}/nvim/spell/de.latin1.sug".source = inputs.nvim-spell-de-latin1-suggestions;
};
};
};
}

View File

@ -20,5 +20,11 @@
upower.enable = lib.mkDefault true;
gvfs.enable = lib.mkDefault true;
};
qt = {
enable = true;
platformTheme = "qt5ct";
style= "kvantum";
};
};
}

View File

@ -13,6 +13,4 @@ lib.mkIf config.desktop.enable {
pulse.enable = true;
wireplumber.enable = true;
};
sound.enable = true;
}

View File

@ -1,9 +1,8 @@
{
lib,
config,
vars,
pkgs,
...
{ lib
, config
, vars
, pkgs
, ...
}: {
imports = [
./i18n.nix
@ -29,6 +28,7 @@
vicious
];
};
};
libinput = {
enable = true;
@ -44,5 +44,4 @@
};
};
};
};
}

View File

@ -4,7 +4,12 @@ let
pattern,
indentSize ? 4,
expandTab ? true,
spell ? false,
}: let
spell =
if expandTab
then "true"
else "false";
expandtab =
if expandTab
then "true"
@ -19,6 +24,7 @@ let
setlocal.expandtab = ${expandtab}
setlocal.shiftwidth = ${builtins.toString indentSize}
setlocal.tabstop = ${builtins.toString indentSize}
setlocal.spell = ${spell}
end
'';
};
@ -39,5 +45,9 @@ in {
expandTab = false;
indentSize = 4;
})
(mkFileTypeOptions {
pattern = ["*.norg"];
spell = true;
})
];
}

View File

@ -9,8 +9,62 @@
config = {
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim;
viAlias = true;
vimAlias = true;
performance = {
byteCompileLua = {
enable = true;
configs = true;
initLua = true;
nvimRuntime = true;
plugins = true;
};
combinePlugins = {
enable = false;
standalonePlugins = [
"nvim-treesitter"
];
};
};
#package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim;
extraPackages = with pkgs; [
fd
ripgrep
iferr
fswatch
reftools
libxcrypt
xz
icu74
nixpkgs-fmt
python3Packages.six
asm-lsp
];
extraPlugins = with pkgs.vimPlugins; [
{
plugin = go-nvim;
config = ''lua require("go").setup()'';
}
{
plugin = nvim-dap-go;
config = ''lua require("dap-go").setup()'';
}
{
plugin = telescope-dap-nvim;
config = ''lua require("telescope").load_extension("dap")'';
}
{
plugin = neorg-telescope;
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "guihua";
src = inputs.guihua;
};
}
];
};
}

View File

@ -1,10 +1,10 @@
{
pkgs,
lib,
...
}: let
{ lib
, ...
}:
let
indentSize = 4;
in {
in
{
options = {
programs.nixvim.ai = {
enable = lib.mkEnableOption "AI functions";
@ -50,8 +50,7 @@ in {
mousemoveevent = true;
timeoutlen = 300;
list = true;
#spell = true;
#spelllang = ["de" "en_us"];
spelllang = [ "de" "en_us" ];
helplang = "de";
laststatus = 3;
conceallevel = 0;
@ -59,41 +58,7 @@ in {
signcolumn = "yes";
foldlevel = 999;
};
extraPackages = with pkgs; [
fd
ripgrep
iferr
fswatch
reftools
golines
richgo
gofumpt
govulncheck
mockgen
ginkgo
gotestsum
libxcrypt
xz
icu74
alejandra
vscode-extensions.ms-vscode.cpptools
nixpkgs-fmt
asm-lsp
];
extraPlugins = with pkgs.vimPlugins; [
{
plugin = go-nvim;
config = ''lua require("go").setup()'';
}
{
plugin = nvim-dap-go;
config = ''lua require("dap-go").setup()'';
}
{
plugin = telescope-dap-nvim;
config = ''lua require("telescope").load_extension("dap")'';
}
];
extraConfigLua = ''
vim.opt.undodir = vim.fn.stdpath("state") .. "/undo"
vim.opt.backupdir = vim.fn.stdpath("state") .. "/backup"
@ -127,6 +92,9 @@ in {
'';
extraConfigLuaPre = ''
vim.opt.runtimepath:prepend(',~/.config/nvim')
vim.opt.runtimepath:append(',~/.config/nvim/after')
local colors = require("catppuccin.palettes").get_palette("mocha")
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")

View File

@ -9,15 +9,9 @@
};
adapters = {
executables = {
lldb = {
command = "${pkgs.llvmPackages.lldb}/bin/lldb-vscode";
};
};
servers.codelldb = rec {
port = 13000;
executable = {
command = "${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb";
args = ["--port" (builtins.toString port)];
gdb = {
command = "${pkgs.gdb}/bin/gdb";
args = ["--interpreter=dap" "--eval-command" "set pretty print on"];
};
};
};
@ -28,10 +22,10 @@
{
name = "Launch";
request = "launch";
type = "codelldb";
type = "gdb";
cwd = "\${workspaceFolder}";
stopOnEntry = false;
runInTerminal = false;
runInTerminal = true;
program = {
__raw = ''
get_program
@ -41,10 +35,10 @@
{
name = "Launch with Arguments";
request = "launch";
type = "codelldb";
type = "gdb";
cwd = "\${workspaceFolder}";
stopOnEntry = false;
runInTerminal = false;
runInTerminal = true;
program = {
__raw = ''
get_program

View File

@ -17,6 +17,7 @@
./treesitter.nix
./trouble.nix
./undotree.nix
./notify.nix
];
plugins = {

View File

@ -1,6 +1,7 @@
{pkgs, ...}: {
{ pkgs, config, lib, ... }: {
plugins.lualine = {
enable = true;
settings = {
sections = {
lualine_a = [ "" "mode" ];
lualine_b = [
@ -9,14 +10,13 @@
];
lualine_c = [
{
name = "filetype";
extraConfig = {icon_only = true;};
__unkeyed-1 = "filetype";
icon_only = true;
}
"filename"
"diagnostics"
{
name = "lsp_progress";
extraConfig = {
__unkeyed-1 = "lsp_progress";
display_components = [
"lsp_client_name"
[
@ -27,12 +27,11 @@
];
colors = {
use = true;
lsp_client_name = { __raw = "colors.sapphire"; };
percentage = { __raw = "colors.blue"; };
spinner = { __raw = "colors.blue"; };
title = { __raw = "colors.subtext1"; };
message = { __raw = "colors.subtext0"; };
};
lsp_client_name = lib.nixvim.mkRaw "colors.sapphire";
percentage = lib.nixvim.mkRaw "colors.blue";
spinner = lib.nixvim.mkRaw "colors.blue";
title = lib.nixvim.mkRaw "colors.subtext1";
message = lib.nixvim.mkRaw "colors.subtext0";
};
}
];
@ -48,39 +47,41 @@
winbar = {
lualine_x = [
{
name = "filename";
extraConfig = {path = 1;};
__unkeyed-1 = "filename";
path = 1;
}
{
name = "filetype";
extraConfig = {icon_only = true;};
__unkeyed-1 = "filetype";
icon_only = true;
}
];
};
inactiveWinbar = {
inactive_winbar = {
lualine_x = [
"diagnostics"
{
name = "filename";
extraConfig = {path = 1;};
__unkeyed-1 = "filename";
path = 1;
}
{
name = "filetype";
extraConfig = {icon_only = true;};
__unkeyed-1 = "filetype";
icon_only = true;
}
];
};
extensions = [ "fugitive" "lazy" "man" "neo-tree" "nvim-dap-ui" "quickfix" ];
componentSeparators = {
options = {
theme = "catppuccin";
component_separators = {
left = "";
right = "";
};
sectionSeparators = {
section_separators = {
left = "";
right = "";
};
theme = "catppuccin";
disabledFiletypes = {
};
disabled_filetypes = {
statusline = [ ];
winbar = [
"help"
@ -96,6 +97,7 @@
];
};
};
};
extraPlugins = with pkgs.vimPlugins; [
lualine-lsp-progress
];

View File

@ -1,52 +1,40 @@
{vars, ...}: {
{vars, lib, inputs, ...}: {
plugins.neorg = {
enable = true;
modules = {
"core.defaults" = {
__empty = null;
};
"core.concealer" = {
config = {
init_open_folds = "auto";
};
};
"core.defaults" = lib.nixvim.emptyTable;
"core.dirman" = {
config = {
inherit (vars.notes) workspaces;
default_workspace = "general";
};
};
"core.concealer" = {
config = {
init_open_folds = "auto";
};
};
"core.completion" = {
config = {
engine = "nvim-cmp";
};
};
"core.summary" = {
__empty = null;
};
"core.tangle" = {
__empty = null;
};
"core.export" = {
config = {
export_dir = "~/Sync/notes-export";
};
};
"core.export.markdown" = {
__empty = null;
};
"core.esupports.metagen" = {
config = {
type = "auto";
author = vars.name;
};
};
"core.integrations.telescope" = {
__empty = null;
};
"core.ui.calendar" = {
__empty = null;
};
"core.export.markdown" = lib.nixvim.emptyTable;
"core.summary" = lib.nixvim.emptyTable;
"core.tangle" = lib.nixvim.emptyTable;
"core.integrations.telescope" = lib.nixvim.emptyTable;
"core.ui.calendar" = lib.nixvim.emptyTable;
};
};
keymaps = [

View File

@ -13,7 +13,7 @@
formatting = {
phpcbf.enable = true;
goimports.enable = true;
asmfmt.enable = true;
#asmfmt.enable = true;
};
};
};

View File

@ -0,0 +1,6 @@
{ lib, ... }: {
plugins.notify = {
enable = true;
render = lib.nixvim.mkRaw "'wrapped-compact'";
};
}

View File

@ -4,9 +4,13 @@
enable = true;
settings = {
indent.enable = true;
highlight.enable = true;
};
folding = true;
grammarPackages = [ inputs.treesitter-grammars.packages.${pkgs.system}.nvim-grammar-bundle ];
nixGrammars = true;
grammarPackages = [
inputs.treesitter-grammars.packages.${pkgs.system}.default
];
};
treesitter-context.enable = true;
ts-autotag.enable = true;

8
overlays/default.nix Normal file
View File

@ -0,0 +1,8 @@
{ inputs, ... }: [
(import ./neorg.nix { inherit inputs; })
(import ./kodi.nix { })
inputs.neovim-nightly-overlay.overlays.default
inputs.nixvim.overlays.default
inputs.nur.overlay
inputs.nixgl.overlay
]

14
overlays/kodi.nix Normal file
View File

@ -0,0 +1,14 @@
_: final: prev: {
kodi-standalone =
final.kodi-wayland.withPackages
(kodiPkgs:
with kodiPkgs; [
youtube
pvr-iptvsimple
keymap
inputstream-adaptive
inputstream-ffmpegdirect
requests-cache
inputstreamhelper
]);
}

64
overlays/neorg.nix Normal file
View File

@ -0,0 +1,64 @@
{inputs,...}: final: prev:
let
inherit (inputs) norg norg-meta neorg neorg-telescope;
inherit (final.lib) attrValues elem filter filterAttrs isDerivation;
in
{
vimPlugins = prev.vimPlugins.extend (f: p: {
nvim-treesitter =
let
norgGrammars = {
tree-sitter-norg = norg.defaultPackage.${final.system};
tree-sitter-norg-meta = norg-meta.defaultPackage.${final.system};
};
builtGrammars = (filterAttrs (_: isDerivation) p.nvim-treesitter.builtGrammars) // norgGrammars;
allGrammars = attrValues builtGrammars;
withPlugins = grammarFn:
p.nvim-treesitter.withPlugins (
_:
let
plugins = grammarFn builtGrammars;
in
plugins ++ (filter (p: !(elem p plugins)) (attrValues norgGrammars))
);
withAllGrammars = withPlugins (_: allGrammars);
in
p.nvim-treesitter.overrideAttrs (a: {
passthru = a.passthru // {
inherit builtGrammars allGrammars withPlugins withAllGrammars;
grammarPlugins = a.passthru.grammarPlugins // {
norg = norgGrammars.tree-sitter-norg;
norg-meta = norgGrammars.tree-sitter-norg-meta;
};
};
});
lua-utils-nvim = final.vimUtils.buildVimPlugin {
inherit (prev.luaPackages.lua-utils-nvim) pname version src;
};
pathlib-nvim = final.vimUtils.buildVimPlugin {
inherit (prev.luaPackages.pathlib-nvim) pname version src;
};
neorg = final.vimUtils.buildVimPlugin {
pname = "neorg";
version = neorg.rev;
src = neorg;
dependencies = [
#(f.nvim-treesitter.withPlugins (_: [ ]))
f.lua-utils-nvim
f.nui-nvim
f.nvim-nio
f.pathlib-nvim
f.plenary-nvim
];
};
neorg-telescope = final.vimUtils.buildVimPlugin {
pname = "neorg-telescope";
version = neorg-telescope.rev;
src = neorg-telescope;
dependencies = [
f.telescope-nvim
f.neorg
];
};
});
}

View File

@ -4,15 +4,12 @@
inputs,
flakeLib,
vars,
overlays,
...
}: let
nixvim' = inputs.nixvim.legacyPackages.${system};
pkgs = flakeLib.mkPkgs {
inherit system nixpkgs;
overlays = [
inputs.neovim-nightly-overlay.overlays.default
inputs.neorg-overlay.overlays.default
];
inherit system nixpkgs overlays;
};
module = {
inherit pkgs;

View File

@ -9,6 +9,10 @@
outputs.homeManagerModules.development
];
programs = {
ghidra.enable = false;
};
home.packages = with pkgs; [
go
];

View File

@ -1,7 +1,6 @@
{
outputs,
vars,
...
{ outputs
, vars
, ...
}: {
imports = [
outputs.nixosModules.home-manager

View File

@ -0,0 +1,25 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix gitignore;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
(final: prev: (import "${fetchTree gitignore.locked}/default.nix") {
inherit (prev) lib;
})
];
}
)
, gitignoreSource ? pkgs.gitignoreSource
, name
, version
}:
pkgs.mkDerivation {
inherit version;
pname = name;
pwd = ./.;
src = gitignoreSource ./.;
modules = ./gomod2nix.toml;
}

57
templates/empty/flake.nix Normal file
View File

@ -0,0 +1,57 @@
{
outputs =
{ self
, nixpkgs
, flake-utils
, gitignore
, git-hooks
, ...
}:
let
name = "project";
version = "0.0.0";
in
{ }
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
gitignore.overlay
];
};
in
{
devShells.default = pkgs.callPackage ./shell.nix {
inherit (self.outputs.checks.${system}) pre-commit-check;
inherit name version;
};
packages.default = pkgs.callPackage ./. { inherit name version; };
checks = {
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
};
};
formatter = pkgs.nixpkgs-fmt;
});
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/x86_64-linux";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}

11
templates/empty/shell.nix Normal file
View File

@ -0,0 +1,11 @@
{ pkgs
, name
, pre-commit-check
, ...
}:
pkgs.mkShell {
inherit (pre-commit-check) shellHook;
buildInputs = pre-commit-check.enabledPackages;
name = "${name}-dev";
packages = [ ];
}

31
templates/go/.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
# Direnv
.direnv
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go
### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# Go workspace file
go.work
# End of https://www.toptal.com/developers/gitignore/api/go

29
templates/go/default.nix Normal file
View File

@ -0,0 +1,29 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix gitignore;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
(final: prev: (import "${fetchTree gitignore.locked}/default.nix") {
inherit (prev) lib;
})
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
, gitignoreSource ? pkgs.gitignoreSource
, name
, version
}:
buildGoApplication {
inherit version;
pname = name;
pwd = ./.;
src = gitignoreSource ./.;
modules = ./gomod2nix.toml;
ldflags = [
"-w -s"
];
}

67
templates/go/flake.nix Normal file
View File

@ -0,0 +1,67 @@
{
outputs =
{ self
, nixpkgs
, flake-utils
, gomod2nix
, gitignore
, git-hooks
, ...
}:
let
name = "project";
version = "0.0.0";
in
{ }
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
gomod2nix.overlays.default
gitignore.overlay
];
};
in
{
devShells.default = pkgs.callPackage ./shell.nix {
inherit (self.outputs.checks.${system}) pre-commit-check;
inherit name version;
};
packages.default = pkgs.callPackage ./. { inherit name version; };
checks = {
pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
gofmt.enable = true;
govet.enable = true;
golangci-lint.enable = true;
};
};
};
formatter = pkgs.nixpkgs-fmt;
});
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/x86_64-linux";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
gomod2nix = {
url = "github:marksisson/gomod2nix?ref=patches/fix-mkgoenv-to-allow-passing-more-attributes";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.gitignore.follows = "gitignore";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}

49
templates/go/shell.nix Normal file
View File

@ -0,0 +1,49 @@
{ pkgs
, name
, mkGoEnv
, gomod2nix
, pre-commit-check
, go
, gotools
, go-tools
, delve
, golines
, richgo
, gotestsum
, golangci-lint
, gotests
, gomodifytags
, gofumpt
, govulncheck
, mockgen
, ginkgo
, ...
}:
let
goEnv = mkGoEnv {
inherit go;
pwd = ./.;
};
in
pkgs.mkShell {
inherit (pre-commit-check) shellHook;
buildInputs = pre-commit-check.enabledPackages;
name = "${name}-dev";
packages = [
goEnv
gomod2nix
gotools
go-tools
golines
richgo
gotestsum
gotests
delve
golangci-lint
gomodifytags
gofumpt
govulncheck
mockgen
ginkgo
];
}