From f73cc70bd185a0c6ab5d7401510930307f5a6083 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Thu, 25 Nov 2021 19:35:21 +0100 Subject: [PATCH] use flakes to handle software not in repos --- flake.lock | 377 +++++++++++++++++++++++++++++++ flake.nix | 74 ++++++ home.nix | 77 +++---- nixos/configuration.nix | 4 +- nixos/hardware-configuration.nix | 32 +++ nixos/pkg.nix | 24 -- 6 files changed, 513 insertions(+), 75 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nixos/hardware-configuration.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e996738 --- /dev/null +++ b/flake.lock @@ -0,0 +1,377 @@ +{ + "nodes": { + "dotacat": { + "flake": false, + "locked": { + "lastModified": 1621958012, + "narHash": "sha256-GaXnSxYVZJQqND4W6lw9XLH1cmBMWhuRn7MCUcmFCdg=", + "ref": "master", + "rev": "7a6284166f0e6cc91fa19ece5b8dce96bfd1e561", + "revCount": 25, + "type": "git", + "url": "https://gitlab.scd31.com/stephen/dotacat.git" + }, + "original": { + "type": "git", + "url": "https://gitlab.scd31.com/stephen/dotacat.git" + } + }, + "fast-syntax-highlighting": { + "flake": false, + "locked": { + "lastModified": 1636861870, + "narHash": "sha256-Rteua+181hxhVLtM/bNj1FIe8H90vXbClTqdi1ppBgI=", + "owner": "z-shell", + "repo": "fast-syntax-highlighting", + "rev": "03c6cc526a586ee4fa0afd7ac05c8b40246a97f8", + "type": "github" + }, + "original": { + "owner": "z-shell", + "repo": "fast-syntax-highlighting", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1637825539, + "narHash": "sha256-TmSZRsBA59HHv6Dym3ZGm2eZDa2z5EmfyAA5F5tW03Q=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c27c8f49c0bccaff91f5f637ad727d440b769997", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1637576998, + "narHash": "sha256-bGQ66hh4Dl78T9bd1pqdp6fprHMCkrkeKqED6sDUYqo=", + "owner": "nix-community", + "repo": "naersk", + "rev": "b043f2447a4a761529254f4983cacd94b034a122", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "naersk_2": { + "inputs": { + "nixpkgs": [ + "rnix-lsp", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1629707199, + "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", + "owner": "nmattia", + "repo": "naersk", + "rev": "df71f5e4babda41cd919a8684b72218e2e809fa9", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "neovim-flake": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "dir": "contrib", + "lastModified": 1637815542, + "narHash": "sha256-8Zj8ij2z2HYI/Kw1YOyghluiLdY44gLOZBfxUPVaj/M=", + "owner": "neovim", + "repo": "neovim", + "rev": "b5b025f6a3ad406929c096f63b5f1e7649d3c818", + "type": "github" + }, + "original": { + "dir": "contrib", + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1637828025, + "narHash": "sha256-2Msh+uQlQJVa065Qb+yA73SqHbpTSusuG225RXmXF9w=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "b5160d7ece844fe5e7e7528f1d0f76f9ccb272f0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "nix-zsh-completions": { + "flake": false, + "locked": { + "lastModified": 1614026477, + "narHash": "sha256-TWgo56l+FBXssOYWlAfJ5j4pOHNmontOEolcGdihIJs=", + "owner": "spwhitt", + "repo": "nix-zsh-completions", + "rev": "468d8cf752a62b877eba1a196fbbebb4ce4ebb6f", + "type": "github" + }, + "original": { + "owner": "spwhitt", + "repo": "nix-zsh-completions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1637864064, + "narHash": "sha256-sTYv7jYztywVNbyyT1yZyKXEdWPnP9Gd0tldkYMKE4k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3ecace59a4414cef3be1344e4f5a900901fb037a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-mozilla": { + "flake": false, + "locked": { + "lastModified": 1637337116, + "narHash": "sha256-LKqAcdL+woWeYajs02bDQ7q8rsqgXuzhC354NoRaV80=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "cbc7435f5b0b3d17b16fb1d20cf7b616eec5e093", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1637869728, + "narHash": "sha256-EyNEFePqeOlYIFLnIbLPgq3C5yWsqxn+DgQzJNTL1Ns=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4b5c3d9376a829f454d195d0c8053a160f6b4fbe", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1637753138, + "narHash": "sha256-yo7E4a/miP77fH3Ksp9tmYECAPjxBeweJFeZ4tX9O/U=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "39cb89ef2ffcbef8d2ac2d52267ac69121a6becb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1637841632, + "narHash": "sha256-QYqiKHdda0EOnLGQCHE+GluD/Lq2EJj4hVTooPM55Ic=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "73369f8d0864854d1acfa7f1e6217f7d6b6e3fa1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1630481079, + "narHash": "sha256-leWXLchbAbqOlLT6tju631G40SzQWPqaAXQG3zH1Imw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "110a2c9ebbf5d4a94486854f18a37a938cfacbbb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "powerlevel10k": { + "flake": false, + "locked": { + "lastModified": 1636957611, + "narHash": "sha256-XJ7gWcAq+xFqCbC3bTBWGTZ0ouftANInJ0fc2uptbco=", + "owner": "romkatv", + "repo": "powerlevel10k", + "rev": "a9f208c8fc509b9c591169dd9758c48ad4325f76", + "type": "github" + }, + "original": { + "owner": "romkatv", + "repo": "powerlevel10k", + "type": "github" + } + }, + "rnix-lsp": { + "inputs": { + "naersk": "naersk_2", + "nixpkgs": "nixpkgs_5", + "utils": "utils" + }, + "locked": { + "lastModified": 1636977689, + "narHash": "sha256-pQmAxKBoEhC851iRsowMErz9CYiJxGpARjhPeSapH1Y=", + "owner": "nix-community", + "repo": "rnix-lsp", + "rev": "9462b0d20325a06f7e43b5a0469ec2c92e60f5fe", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "rnix-lsp", + "type": "github" + } + }, + "root": { + "inputs": { + "dotacat": "dotacat", + "fast-syntax-highlighting": "fast-syntax-highlighting", + "home-manager": "home-manager", + "naersk": "naersk", + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nix-zsh-completions": "nix-zsh-completions", + "nixpkgs": "nixpkgs_4", + "nixpkgs-mozilla": "nixpkgs-mozilla", + "powerlevel10k": "powerlevel10k", + "rnix-lsp": "rnix-lsp", + "stylua": "stylua", + "zsh-nix-shell": "zsh-nix-shell" + } + }, + "stylua": { + "flake": false, + "locked": { + "lastModified": 1637341087, + "narHash": "sha256-F70PZ51MeLjsbYqIMo4b6I5jgvndIRdIrCleE72uVLg=", + "owner": "johnnymorganz", + "repo": "stylua", + "rev": "027acfd700c3d2a404ef77c92648dca3e0f9e69e", + "type": "github" + }, + "original": { + "owner": "johnnymorganz", + "repo": "stylua", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "zsh-nix-shell": { + "flake": false, + "locked": { + "lastModified": 1628023704, + "narHash": "sha256-WNa8RljYhkOWk7AZbdTOvYhWw1fR8PjFxH/tnUCbems=", + "owner": "chisui", + "repo": "zsh-nix-shell", + "rev": "f8574f27e1d7772629c9509b2116d504798fe30a", + "type": "github" + }, + "original": { + "owner": "chisui", + "repo": "zsh-nix-shell", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..69c9efe --- /dev/null +++ b/flake.nix @@ -0,0 +1,74 @@ +{ + description = "NixOS configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; + nixpkgs-mozilla = { + url = "github:mozilla/nixpkgs-mozilla"; + flake = false; + }; + dotacat = { + url = "git+https://gitlab.scd31.com/stephen/dotacat.git"; + flake = false; + }; + rnix-lsp.url = "github:nix-community/rnix-lsp"; + stylua = { + url = "github:johnnymorganz/stylua"; + flake = false; + }; + naersk.url = "github:nix-community/naersk"; + fast-syntax-highlighting = { + url = "github:z-shell/fast-syntax-highlighting"; + flake = false; + }; + zsh-nix-shell = { + url = "github:chisui/zsh-nix-shell"; + flake = false; + }; + nix-zsh-completions = { + url = "github:spwhitt/nix-zsh-completions"; + flake = false; + }; + powerlevel10k = { + url = "github:romkatv/powerlevel10k"; + flake = false; + }; + }; + + outputs = { home-manager, nixpkgs, ... }@inputs: { + nixosConfigurations = { + ZeNixLaptop = nixpkgs.lib.nixosSystem rec { + system = "x86_64-linux"; + modules = [ + ({ pkgs, ... }: { + nixpkgs.overlays = [ + inputs.neovim-nightly-overlay.overlay + (import inputs.nixpkgs-mozilla) + ]; + }) + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.traxys = import ./home.nix; + home-manager.extraSpecialArgs = { + dotacat = inputs.dotacat; + rnix-lsp = inputs.rnix-lsp; + stylua = inputs.stylua; + naersk-lib = inputs.naersk.lib."${system}"; + fast-syntax-highlighting = inputs.fast-syntax-highlighting; + zsh-nix-shell = inputs.zsh-nix-shell; + nix-zsh-completions = inputs.nix-zsh-completions; + powerlevel10k = inputs.powerlevel10k; + }; + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + } + ]; + }; + }; + }; +} diff --git a/home.nix b/home.nix index dc31af0..78a52a9 100644 --- a/home.nix +++ b/home.nix @@ -1,4 +1,15 @@ -{ config, pkgs, lib, ... }: +{ config +, pkgs +, lib +, dotacat +, stylua +, naersk-lib +, fast-syntax-highlighting +, zsh-nix-shell +, nix-zsh-completions +, powerlevel10k +, ... +}: let rustVersion = (pkgs.rustChannelOf { channel = "stable"; }).rust; @@ -7,12 +18,6 @@ let rustc = rustVersion; }; localinfo = import ./localinfo.nix; - pkgCratesIO = { name, version, hash }: rsPlatform.buildRustPackage { - pname = name; - version = version; - src = fetchTarball "https://static.crates.io/crates/${name}/${name}-${version}.crate"; - cargoSha256 = hash; - }; in { imports = [ @@ -37,17 +42,18 @@ in nodePackages.vscode-json-languageserver nodePackages.bash-language-server nixpkgs-fmt - (import (builtins.fetchTarball { - url = https://github.com/nix-community/rnix-lsp/archive/master.tar.gz; - })) + rnix-lsp exa python3 topgrade wl-clipboard - (pkgCratesIO { - name = "dotacat"; - version = "0.2.0"; - hash = "1lnmw0c7m40ysbar8bk6r2jh32w6613457r5wgp418pgy2300kvn"; + (naersk-lib.buildPackage { + pname = "dotacat"; + root = dotacat; + }) + (naersk-lib.buildPackage { + pname = "stylua"; + root = stylua; }) cargo-edit rsync @@ -57,19 +63,12 @@ in httpie sqlx-cli direnv - (rsPlatform.buildRustPackage rec { - pname = "stylua"; - version = "0.11.0"; - src = fetchFromGitHub { - owner = "johnnymorganz"; - repo = "stylua"; - rev = "0caa9a2"; - sha256 = "1r6jr2ghha6wklm2bwrixmq0r4h5vrvaryrz11q6hpfwpicpdnn1"; - }; - cargoSha256 = "0v2154qd4m8yqpv0v4ikhymd693p0bbf8vxf7h5bzb4d9vaxxb6m"; - }) codespell shellcheck + ripgrep + file + jq + wget ]; services = { @@ -118,32 +117,17 @@ in { name = "fast-syntax-highlighting"; file = "fast-syntax-highlighting.plugin.zsh"; - src = pkgs.fetchFromGitHub { - owner = "zdharma"; - repo = "fast-syntax-highlighting"; - rev = "817916dfa907d179f0d46d8de355e883cf67bd97"; - sha256 = "0m102makrfz1ibxq8rx77nngjyhdqrm8hsrr9342zzhq1nf4wxxc"; - }; + src = fast-syntax-highlighting; } { name = "zsh-nix-shell"; file = "nix-shell.plugin.zsh"; - src = pkgs.fetchFromGitHub { - owner = "chisui"; - repo = "zsh-nix-shell"; - rev = "v0.4.0"; - sha256 = "1gfyrgn23zpwv1vj37gf28hf5z0ka0w5qm6286a7qixwv7ijnrx9"; - }; + src = zsh-nix-shell; } { name = "nix-zsh-completions"; file = "nix-zsh-completions.plugin.zsh "; - src = pkgs.fetchFromGitHub { - owner = "spwhitt"; - repo = "nix-zsh-completions"; - rev = "0.4.4"; - sha256 = "1n9whlys95k4wc57cnz3n07p7zpkv796qkmn68a50ygkx6h3afqf"; - }; + src = nix-zsh-completions; } ]; initExtra = @@ -175,12 +159,7 @@ in recursive = true; }; ".powerlevel10k" = { - source = pkgs.fetchFromGitHub { - owner = "romkatv"; - repo = "powerlevel10k"; - rev = "v1.15.0"; - sha256 = "1b3j2riainx3zz4irww72z0pb8l8ymnh1903zpsy5wmjgb0wkcwq"; - }; + source = powerlevel10k; }; ".zprofile".source = ./zprofile; ".p10k.zsh".source = ./p10k.zsh; diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 6af9b36..b144b4d 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -8,9 +8,9 @@ imports = [ # Include the results of the hardware scan. - /etc/nixos/hardware-configuration.nix + ./hardware-configuration.nix ./pkg.nix - ./home.nix + #./home.nix ./localcfg.nix ]; diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix new file mode 100644 index 0000000..b2d9a36 --- /dev/null +++ b/nixos/hardware-configuration.nix @@ -0,0 +1,32 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + boot.kernelParams = [ "iomem=relaxed" ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/95baa216-c7f1-418d-be70-cd1d4102c837"; + fsType = "btrfs"; + }; + + fileSystems."/home" = + { + device = "/dev/disk/by-uuid/50e43b17-10c8-4bbe-893a-c709172867db"; + fsType = "btrfs"; + }; + + swapDevices = [ + ]; +} diff --git a/nixos/pkg.nix b/nixos/pkg.nix index 033ec76..12f2da3 100644 --- a/nixos/pkg.nix +++ b/nixos/pkg.nix @@ -23,15 +23,6 @@ allowUnfree = true; }; - nixpkgs.overlays = [ - (import (builtins.fetchTarball { - url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz; - })) - (import (builtins.fetchTarball { - url = https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz; - })) - ]; - /* nixpkgs.config.packageOverrides = pkgs: { steam = pkgs.steam.override { nativeOnly = true; @@ -39,19 +30,4 @@ }; */ programs.steam.enable = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - wget - neovim-nightly - git - gnumake - ripgrep - flashrom - gcc - libappindicator - file - jq - ]; }