From c3f40df266b0e0ae2659d4b3a045a4ee2147533f Mon Sep 17 00:00:00 2001 From: SouthFox Date: Fri, 15 Nov 2024 00:15:38 +0800 Subject: [PATCH] init --- .gitignore | 7 ++++ flake.lock | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++ home.nix | 82 ++++++++++++++++++++++++++++++++++++++++++ system.nix | 41 +++++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 system.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ca9e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.idea +*.log +tmp/ + +.config/ +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ca4e0de --- /dev/null +++ b/flake.lock @@ -0,0 +1,102 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731235328, + "narHash": "sha256-NjavpgE9/bMe/ABvZpyHIUeYF1mqR5lhaep3wB79ucs=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "60bb110917844d354f3c18e05450606a435d2d10", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "system-manager": "system-manager" + } + }, + "system-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731533503, + "narHash": "sha256-nzJYpa8fUVzd9Ej/AWrFDO/ZANaI6r5bK1zxayHJJRg=", + "owner": "numtide", + "repo": "system-manager", + "rev": "19f20fe6e4a8df8473ca4da0e8d70543e97d868b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "system-manager", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b5e9ba2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "deck thing"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + system-manager = { + url = "github:numtide/system-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, home-manager, flake-utils, system-manager, ... }: { + homeConfigurations.deck = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; }; + + # Specify your home configuration modules here, for example, + # the path to your home.nix. + modules = [ ./home.nix ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + + systemConfigs.default = system-manager.lib.makeSystemConfig { + extraSpecialArgs.pkgs = import nixpkgs { system = "x86_64-linux"; config.allowUnfree = true; }; + modules = [ + ./system.nix + ]; + }; + + }; +} + diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..1da9154 --- /dev/null +++ b/home.nix @@ -0,0 +1,82 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "deck"; + home.homeDirectory = "/home/deck"; + + # 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 = [ + pkgs.emacs + pkgs.firefox + # # 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/chn/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # services.zerotierone.enable = true; + #services.gpg-agent.enable = true; + +} diff --git a/system.nix b/system.nix new file mode 100644 index 0000000..7e597c7 --- /dev/null +++ b/system.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + nixpkgs.hostPlatform = "x86_64-linux"; + system-manager.allowAnyDistro = true; + + environment = { + systemPackages = [ + pkgs.zerotierone + ]; + }; + + systemd.services = { + sshd = { + enable = true; + serviceConfig = { + Type = "notify-reload"; + ExecStart = "/usr/bin/sshg -D"; + KillMode = "process"; + Restart = "always"; + }; + wants = [ "sshdgenkeys.service" ]; + after = [ "sshdgenkeys.service" "network.target" ]; + wantedBy = [ "multi-user.target" ]; + }; + + zerotierone = { + enable = true; + serviceConfig = { + Type = "simple"; + }; + wantedBy = [ "ensure-symlinked-units-resolve.service" "system-manager.target" ]; + script = '' + ${lib.getBin pkgs.zerotierone}/bin/zerotier-one + echo "We launched the rockets!" + ''; + }; + }; + }; +}