Merge pull request #2 from cything/gh-actions

make nix flake check also check formatting in gh actions
This commit is contained in:
cy 2024-12-28 11:54:02 -05:00 committed by GitHub
commit e9897830e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 276 additions and 239 deletions

View file

@ -1,4 +1,4 @@
name: "nix build and flake check" name: "nix flake and fmt check"
on: on:
pull_request: pull_request:
push: push:
@ -11,15 +11,3 @@ jobs:
with: with:
github_access_token: ${{ secrets.github_token }} github_access_token: ${{ secrets.github_token }}
- run: nix flake check - run: nix flake check
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.github_token }}
- name: install nixfmt
run: nix-env -f <nixpkgs> -iAP nixfmt-rfc-style
- name: check that nix files are formatted correctly
run : nixfmt --check

37
flake.lock generated
View file

@ -84,6 +84,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1733097829,
"narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager", "home-manager": "home-manager",
@ -91,7 +107,8 @@
"nixpkgs-borg": "nixpkgs-borg", "nixpkgs-borg": "nixpkgs-borg",
"nixpkgs-evolution": "nixpkgs-evolution", "nixpkgs-evolution": "nixpkgs-evolution",
"nixpkgs-master": "nixpkgs-master", "nixpkgs-master": "nixpkgs-master",
"sops-nix": "sops-nix" "sops-nix": "sops-nix",
"treefmt": "treefmt"
} }
}, },
"sops-nix": { "sops-nix": {
@ -113,6 +130,24 @@
"repo": "sops-nix", "repo": "sops-nix",
"type": "github" "type": "github"
} }
},
"treefmt": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1735135567,
"narHash": "sha256-8T3K5amndEavxnludPyfj3Z1IkcFdRpR23q+T0BVeZE=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "9e09d30a644c57257715902efbb3adc56c79cf28",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -11,6 +11,7 @@
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
treefmt.url = "github:numtide/treefmt-nix";
nixpkgs-borg.url = "github:cything/nixpkgs/borg"; nixpkgs-borg.url = "github:cything/nixpkgs/borg";
nixpkgs-master.url = "github:nixos/nixpkgs/master"; nixpkgs-master.url = "github:nixos/nixpkgs/master";
nixpkgs-evolution.url = "github:nixos/nixpkgs/a49023bcb550bcd84e1fa8afcbe7aa8bc0850bf4"; nixpkgs-evolution.url = "github:nixos/nixpkgs/a49023bcb550bcd84e1fa8afcbe7aa8bc0850bf4";
@ -21,6 +22,7 @@
self, self,
nixpkgs, nixpkgs,
home-manager, home-manager,
treefmt,
... ...
}@inputs: }@inputs:
let let
@ -65,10 +67,22 @@
}; };
} }
); );
treefmtEval = forEachSystem (
pkgs:
treefmt.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixfmt.enable = true;
programs.stylua.enable = true;
}
);
in in
{ {
packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; });
formatter = forEachSystem (pkgs: pkgs.nixfmt-rfc-style); formatter = forEachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
checks = forEachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
nixosConfigurations = nixosConfigurations =
let let

View file

@ -8,13 +8,13 @@ vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true vim.opt.termguicolors = true
require("nvim-tree").setup() require("nvim-tree").setup()
require("lualine").setup { require("lualine").setup({
options = { options = {
theme = "auto", theme = "auto",
icons_enabled = true, icons_enabled = true,
globalstatus = true, globalstatus = true,
} },
} })
require("gitsigns").setup() require("gitsigns").setup()
@ -34,7 +34,7 @@ opt.showmode = false
opt.mouse = "" opt.mouse = ""
opt.wrap = false opt.wrap = false
vim.cmd.colorscheme "iceberg" vim.cmd.colorscheme("iceberg")
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, { keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
desc = "toggle nvim-tree", desc = "toggle nvim-tree",

View file

@ -8,7 +8,7 @@ keymap.set("n", "<leader>fc", fzf.resume, { silent = true })
keymap.set("n", "<leader>fs", fzf.treesitter, { silent = true }) keymap.set("n", "<leader>fs", fzf.treesitter, { silent = true })
keymap.set("n", "<leader>fg", fzf.grep_project, { silent = true }) keymap.set("n", "<leader>fg", fzf.grep_project, { silent = true })
fzf.setup { fzf.setup({
"fzf-native", "fzf-native",
keymap = { keymap = {
fzf = { fzf = {
@ -16,6 +16,6 @@ fzf.setup {
["ctrl-d"] = "half-page-down", ["ctrl-d"] = "half-page-down",
["ctrl-j"] = "preview-page-down", ["ctrl-j"] = "preview-page-down",
["ctrl-k"] = "preview-page-up", ["ctrl-k"] = "preview-page-up",
} },
} },
} })

View file

@ -1,15 +1,15 @@
local hop = require('hop') local hop = require("hop")
local keymap = vim.keymap local keymap = vim.keymap
hop.setup { hop.setup({
case_insensitive = true; case_insensitive = true,
char2_fallback_key = "<CR>", char2_fallback_key = "<CR>",
quit_key = "<Esc", quit_key = "<Esc",
} })
keymap.set({ 'n', 'v', 'o' }, '<C-t>', "", { keymap.set({ "n", "v", "o" }, "<C-t>", "", {
silent = true; silent = true,
noremap = true; noremap = true,
callback = function() callback = function()
hop.hint_char1() hop.hint_char1()
end, end,

View file

@ -8,22 +8,22 @@ keymap.set("n", "gr", lsp.buf.references)
keymap.set("n", "[d", diagnostic.goto_prev) keymap.set("n", "[d", diagnostic.goto_prev)
keymap.set("n", "]d", diagnostic.goto_next) keymap.set("n", "]d", diagnostic.goto_next)
diagnostic.config { diagnostic.config({
signs = false, signs = false,
} })
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
lspconfig.pylsp.setup { capabilities = capabilities } lspconfig.pylsp.setup({ capabilities = capabilities })
lspconfig.clangd.setup { capabilities = capabilities } lspconfig.clangd.setup({ capabilities = capabilities })
lspconfig.vimls.setup { capabilities = capabilities } lspconfig.vimls.setup({ capabilities = capabilities })
lspconfig.bashls.setup { capabilities = capabilities } lspconfig.bashls.setup({ capabilities = capabilities })
lspconfig.rust_analyzer.setup { lspconfig.rust_analyzer.setup({
capabilities = capabilities, capabilities = capabilities,
} })
lspconfig.gopls.setup { lspconfig.gopls.setup({
settings = { settings = {
gopls = { gopls = {
analyses = { analyses = {
@ -31,46 +31,46 @@ lspconfig.gopls.setup {
}, },
staticcheck = true, staticcheck = true,
gofumpt = true, gofumpt = true,
} },
}, },
capabilities = capabilities, capabilities = capabilities,
} })
lspconfig.lua_ls.setup { lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = capabilities,
on_init = function(client) on_init = function(client)
if client.workspace_folders then if client.workspace_folders then
local path = client.workspace_folders[1].name local path = client.workspace_folders[1].name
if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then if vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc") then
return return
end end
end end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = { runtime = {
-- Tell the language server which version of Lua you're using -- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim) -- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT' version = "LuaJIT",
}, },
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
workspace = { workspace = {
checkThirdParty = false, checkThirdParty = false,
library = { library = {
vim.env.VIMRUNTIME vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here. -- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library" -- "${3rd}/luv/library"
-- "${3rd}/busted/library", -- "${3rd}/busted/library",
} },
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
-- library = vim.api.nvim_get_runtime_file("", true) -- library = vim.api.nvim_get_runtime_file("", true)
} },
}) })
end, end,
settings = { settings = {
Lua = {} Lua = {},
} },
} })
lspconfig.nixd.setup { capabilities = capabilities } lspconfig.nixd.setup({ capabilities = capabilities })
lspconfig.sqls.setup { capabilities = capabilities } lspconfig.sqls.setup({ capabilities = capabilities })
lspconfig.hls.setup { capabilities = capabilities } lspconfig.hls.setup({ capabilities = capabilities })

View file

@ -1,10 +1,10 @@
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip"); local luasnip = require("luasnip")
cmp.setup { cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
mapping = { mapping = {
@ -44,11 +44,11 @@ cmp.setup {
end end
end, { "i", "s" }), end, { "i", "s" }),
}, },
sources = cmp.config.sources ({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
}, { }, {
{ name = "buffer" }, { name = "buffer" },
{ name = "path" }, { name = "path" },
}) }),
} })

View file

@ -34,7 +34,7 @@ local plugin_specs = {
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
event = 'VeryLazy', event = "VeryLazy",
dependencies = { dependencies = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
@ -78,19 +78,19 @@ local plugin_specs = {
{ "folke/tokyonight.nvim", lazy = false, priority = 1000 }, { "folke/tokyonight.nvim", lazy = false, priority = 1000 },
{ "lewis6991/gitsigns.nvim"}, { "lewis6991/gitsigns.nvim" },
{ "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } }, { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } },
{ {
'smoka7/hop.nvim', "smoka7/hop.nvim",
version = "*", version = "*",
config = function() config = function()
require("config.hop") require("config.hop")
end, end,
}, },
{ "cocopon/iceberg.vim" } { "cocopon/iceberg.vim" },
} }
require("lazy").setup({ require("lazy").setup({