Initial commit

This commit is contained in:
ktkk 2025-06-05 19:13:28 +00:00
commit b89303566a
6 changed files with 462 additions and 0 deletions

101
flake.lock generated Normal file
View file

@ -0,0 +1,101 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1746413188,
"narHash": "sha256-i6BoiQP0PasExESQHszC0reQHfO6D4aI2GzOwZMOI20=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "8a318641ac13d3bc0a53651feaee9560f9b2d89a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1744290088,
"narHash": "sha256-/X9XVEl0EiyisNbF5srrxXRSVoRqdwExuqyspYqqEjQ=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "60b4904a1390ac4c89e93d95f6ed928975e525ed",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "main",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1742937945,
"narHash": "sha256-lWc+79eZRyvHp/SqMhHTMzZVhpxkRvthsP1Qx6UCq0E=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d02d88f8de5b882ccdde0465d8fa2db3aa1169f7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1746141548,
"narHash": "sha256-IgBWhX7A2oJmZFIrpRuMnw5RAufVnfvOgHWgIdds+hc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f02fddb8acef29a8b32f10a335d44828d7825b78",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

61
flake.nix Normal file
View file

@ -0,0 +1,61 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self, nixpkgs, ... }@inputs:
let
inherit (self) outputs;
system = "x86_64-linux";
in
{
formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-tree;
nixosConfigurations = {
wsl = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
};
inherit system;
modules = [
./hosts/wsl/configuration.nix
inputs.nixos-wsl.nixosModules.default
inputs.home-manager.nixosModules.default
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users = {
nixos = import ./home/nixos/home.nix;
};
};
}
];
};
};
# homeConfiguration = {
# nixos = inputs.home-manager.lib.homeManagerConfiguration {
# extraSpecialArgs = {
# inherit inputs outputs self;
# };
# pkgs = nixpkgs.legacyPackages."x86_64-linux";
# modules = [
# ./home/nixos/home.nix
# ];
# };
# };
};
}

157
home/nixos/home.nix Normal file
View file

@ -0,0 +1,157 @@
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "nixos";
home.homeDirectory = "/home/nixos";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "24.05"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. These will be explicitly sourced when using a
# shell provided by Home Manager. If you don't want to manage your shell
# through Home Manager then you have to manually source 'hm-session-vars.sh'
# located at either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/nixos/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
# EDITOR = "emacs";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
extraConfig = ''
scriptencoding utf-8
set tabstop=4
set shiftwidth=4
set expandtab
set number
set relativenumber
highlight Normal guibg=none
highlight NonText guibg=none
highlight Normal ctermbg=none
highlight NonText ctermbg=none
set list
set listchars=tab:\ ,space:.,nbsp:,precedes:,extends:
'';
plugins = with pkgs.vimPlugins; [
{
plugin = (
nvim-treesitter.withPlugins (
p: with p; [
c
cpp
zig
rust
go
gleam
lua
swift
typescript
javascript
json
nix
]
)
);
config = ''
packadd! nvim-treesitter
lua <<EOF
require("nvim-treesitter.configs").setup({
highlight = {
enable = true,
},
})
EOF
'';
}
{
plugin = nvim-lspconfig;
config = ''
packadd! nvim-lspconfig
lua <<EOF
local lspconfig = require("lspconfig")
lspconfig.gleam.setup({})
EOF
'';
}
];
};
programs.git = {
enable = true;
userName = "ktkk";
userEmail = "dezuttereluka@gmail.com";
extraConfig = {
url."ssh://git@ssh.github.com:443/" = {
insteadOf = "git@github.com:";
};
};
};
programs.direnv = {
enable = true;
};
}

66
hosts/shared/default.nix Normal file
View file

@ -0,0 +1,66 @@
{
pkgs,
outputs,
inputs,
lib,
...
}:
{
environment.systemPackages = with pkgs; [
home-manager
neovim
git
tree
wget
];
programs.direnv = {
enable = true;
};
services.openssh = {
enable = true;
};
networking = {
firewall = {
allowedTCPPorts = [ 22 ];
enable = true;
};
};
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = {
LC_ALL = "en_US.UTF-8";
};
};
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
];
};
gc = {
automatic = true;
options = "--delete-older-than 5d";
};
optimise = {
automatic = true;
};
};
system = {
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
stateVersion = "24.05"; # Did you read the comment?
};
}

View file

@ -0,0 +1,20 @@
{
pkgs,
outputs,
inputs,
lib,
...
}:
{
imports = [
../../modules/grafana
../shared
];
networking.hostName = "wsl";
wsl = {
enable = true;
defaultUser = "nixos";
};
}

View file

@ -0,0 +1,57 @@
{ pkgs, config, ... }:
{
services.grafana = {
enable = true;
settings = {
server = {
http_addr = "127.0.0.1";
http_port = 2342;
domain = "grafana.pele";
};
};
provision = {
datasources.settings.datasources = [
{
name = "Prometheus";
type = "prometheus";
url = "http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}";
}
];
};
};
services.nginx.virtualHosts.${config.services.grafana.settings.server.domain} = {
locations."/" = {
proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}";
proxyWebsockets = true;
};
};
services.prometheus = {
enable = true;
port = 9001;
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
};
scrapeConfigs = [
{
job_name = "nixos";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
];
}
];
}
];
};
}