Save state
This commit is contained in:
parent
fb4e422936
commit
f2e1340ad5
16 changed files with 260 additions and 96 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) niv;
|
||||||
{
|
{
|
||||||
core = pkgs: with pkgs; [
|
core = pkgs: with pkgs; [
|
||||||
gitFull
|
gitFull
|
||||||
|
@ -28,6 +30,7 @@
|
||||||
lorri = import "${lorriSrc}/default.nix" { src = lorriSrc; inherit pkgs; };
|
lorri = import "${lorriSrc}/default.nix" { src = lorriSrc; inherit pkgs; };
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
|
# niv
|
||||||
git-crypt
|
git-crypt
|
||||||
gitAndTools.git-annex
|
gitAndTools.git-annex
|
||||||
htop
|
htop
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> {};
|
pkgs = import <nixpkgs> {};
|
||||||
unstable = import <unstable> {};
|
unstable = import <unstable> {};
|
||||||
|
sources = import ../nix/sources.nix;
|
||||||
shh = unstable.haskell.lib.overrideCabal unstable.haskellPackages.shh (drv: {
|
shh = unstable.haskell.lib.overrideCabal unstable.haskellPackages.shh (drv: {
|
||||||
broken = false;
|
broken = false;
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
});
|
});
|
||||||
writeHaskellScript = { name ? "haskell-script", bins ? [pkgs.coreutils], libraries ? [], imports ? []}: code:
|
writeHaskellScript = { name ? "haskell-script", bins ? [pkgs.coreutils], libraries ? [], imports ? []}: code:
|
||||||
unstable.writers.writeHaskellBin name { libraries = libraries ++ [shh]; } ''
|
unstable.writers.writeHaskellBin name { libraries = libraries ++ [shh unstable.haskellPackages.string-interpolate ]; } ''
|
||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
|
||||||
import Shh
|
import Shh
|
||||||
|
import Data.String.Interpolate (i)
|
||||||
|
import qualified Data.ByteString as BS
|
||||||
|
import qualified Data.ByteString.Lazy as LBS
|
||||||
|
import qualified Data.Text as T
|
||||||
|
import qualified Data.Text.Lazy as LT
|
||||||
|
import qualified Data.Text.Encoding as TE
|
||||||
|
import qualified Data.Text.Lazy.Encoding as LTE
|
||||||
${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)}
|
${builtins.concatStringsSep "\n" (map (x: "import ${x}") imports)}
|
||||||
|
|
||||||
-- Load binaries from Nix packages. The dependencies will be captured
|
-- Load binaries from Nix packages. The dependencies will be captured
|
||||||
|
@ -18,12 +28,10 @@ let
|
||||||
|
|
||||||
${code}
|
${code}
|
||||||
'';
|
'';
|
||||||
in {
|
|
||||||
inherit writeHaskellScript;
|
|
||||||
getNivPath = writeHaskellScript {
|
getNivPath = writeHaskellScript {
|
||||||
name = "get-niv-path";
|
name = "get-niv-path";
|
||||||
bins = [pkgs.nix pkgs.coreutils];
|
bins = [pkgs.nix];
|
||||||
imports = ["System.Console.CmdArgs.Implicit" "Data.Text.Lazy" "Data.Text.Lazy.Encoding"];
|
imports = ["System.Console.CmdArgs.Implicit"];
|
||||||
libraries = [ unstable.haskellPackages.cmdargs unstable.haskellPackages.text ];
|
libraries = [ unstable.haskellPackages.cmdargs unstable.haskellPackages.text ];
|
||||||
} ''
|
} ''
|
||||||
|
|
||||||
|
@ -34,10 +42,17 @@ in {
|
||||||
|
|
||||||
path = Path{ sources = def &= argPos 0, channel = def &= argPos 1}
|
path = Path{ sources = def &= argPos 0, channel = def &= argPos 1}
|
||||||
|
|
||||||
|
trimQuotation = pureProc $ LTE.encodeUtf8 . LT.dropAround ('"' ==) . LTE.decodeUtf8 . trim
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
path <- cmdArgs path
|
path <- cmdArgs path
|
||||||
path <- readTrim $ nix_instantiate "--eval" "-E" ("toString (import " ++ sources path ++ ")." ++ channel path)
|
let expr = [i|(import #{sources path}).#{channel path}|]
|
||||||
echo . unpack . dropAround ('"' ==) $ decodeUtf8 path
|
nix_build ["-Q", "-E", expr, "--no-out-link"] &> devNull
|
||||||
|
nix_instantiate ["--eval", "-E", [i|toString #{expr}|]] |> trimQuotation
|
||||||
'';
|
'';
|
||||||
|
home-manager = pkgs.callPackage <home-manager/home-manager> {};
|
||||||
|
niv = (import sources.niv {}).niv;
|
||||||
|
in {
|
||||||
|
inherit writeHaskellScript home-manager getNivPath unstable niv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,6 @@
|
||||||
{ pkgs, config, ... }:
|
{ pkgs, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (import ../common/my-lib.nix) writeHaskellScript getNivPath;
|
|
||||||
sources = import ../nix/sources.nix;
|
|
||||||
inherit (config.m-0.private) me meWork;
|
inherit (config.m-0.private) me meWork;
|
||||||
configPath = "/home/${config.home.username}/git/nixos/config";
|
|
||||||
gcRetentionDays = 5;
|
|
||||||
update-home-manager = writeHaskellScript
|
|
||||||
{
|
|
||||||
name = "update-home-manager";
|
|
||||||
imports = [
|
|
||||||
"qualified Data.ByteString.Lazy.Char8 as C"
|
|
||||||
"qualified Data.List as L"
|
|
||||||
];
|
|
||||||
bins = [
|
|
||||||
getNivPath
|
|
||||||
(pkgs.callPackage <home-manager/home-manager> {})
|
|
||||||
];
|
|
||||||
}
|
|
||||||
''
|
|
||||||
|
|
||||||
getNivAssign name = fmap tag . readTrim $ get_niv_path "${configPath}/nix/sources.nix" name
|
|
||||||
where tag str = ["-I", name ++ "=" ++ C.unpack str]
|
|
||||||
|
|
||||||
main = do
|
|
||||||
paths <- mapM getNivAssign ["home-manager", "nixpkgs", "unstable"]
|
|
||||||
home_manager (concat paths ++ ["switch"])
|
|
||||||
'';
|
|
||||||
user-maintenance = writeHaskellScript
|
|
||||||
{ name = "user-maintenance"; imports = [ ]; bins = [ update-home-manager pkgs.nix pkgs.git];} ''
|
|
||||||
main = do
|
|
||||||
git "-C" "${configPath}" "pull"
|
|
||||||
update_home_manager
|
|
||||||
nix_collect_garbage "--delete-older-than" "${toString gcRetentionDays}"
|
|
||||||
nix "optimise-store"
|
|
||||||
'';
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -65,13 +32,6 @@ nixpkgs.overlays = [ (self: super: {
|
||||||
neovim = (import ./nvim) super config.m-0.rustdev.enable;
|
neovim = (import ./nvim) super config.m-0.rustdev.enable;
|
||||||
})];
|
})];
|
||||||
|
|
||||||
home.file = {
|
|
||||||
home-manager-source = {
|
|
||||||
target = ".nix-path/home-manager";
|
|
||||||
source = sources.home-manager;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
home-manager.enable = true;
|
home-manager.enable = true;
|
||||||
direnv = {
|
direnv = {
|
||||||
|
@ -152,7 +112,6 @@ programs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
NIX_PATH = "$HOME/.nix-path:$NIX_PATH";
|
|
||||||
PATH = "$HOME/.cargo/bin:/etc/profiles/per-user/${config.home.username}/bin:$HOME/.nix-profile/bin:$PATH";
|
PATH = "$HOME/.cargo/bin:/etc/profiles/per-user/${config.home.username}/bin:$HOME/.nix-profile/bin:$PATH";
|
||||||
BROWSER = "${pkgs.firefox}/bin/firefox";
|
BROWSER = "${pkgs.firefox}/bin/firefox";
|
||||||
EDITOR = "${pkgs.neovim}/bin/nvim";
|
EDITOR = "${pkgs.neovim}/bin/nvim";
|
||||||
|
@ -177,7 +136,6 @@ services = {
|
||||||
|
|
||||||
home.packages = builtins.attrValues {
|
home.packages = builtins.attrValues {
|
||||||
inherit (pkgs) neovim;
|
inherit (pkgs) neovim;
|
||||||
inherit update-home-manager user-maintenance;
|
|
||||||
print215 = (pkgs.writeShellScriptBin "print215" ''
|
print215 = (pkgs.writeShellScriptBin "print215" ''
|
||||||
scp "$@" ag-forward:
|
scp "$@" ag-forward:
|
||||||
ssh ag-forward lpr -Zduplex -r "$@"
|
ssh ag-forward lpr -Zduplex -r "$@"
|
||||||
|
|
26
home-manager/lib.nix
Normal file
26
home-manager/lib.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) home-manager writeHaskellScript getNivPath;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
update-home-manager = configPath: writeHaskellScript
|
||||||
|
{
|
||||||
|
name = "update-home-manager";
|
||||||
|
imports = [
|
||||||
|
"qualified Data.ByteString.Lazy.Char8 as C"
|
||||||
|
"qualified Data.List as L"
|
||||||
|
];
|
||||||
|
bins = [
|
||||||
|
getNivPath
|
||||||
|
home-manager
|
||||||
|
];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
|
||||||
|
getNivAssign name = fmap tag . readTrim $ get_niv_path "${configPath}/nix/sources.nix" name
|
||||||
|
where tag str = ["-I", name ++ "=" ++ C.unpack str]
|
||||||
|
|
||||||
|
main = do
|
||||||
|
paths <- mapM getNivAssign ["home-manager", "nixpkgs", "unstable"]
|
||||||
|
home_manager (concat paths ++ ["switch"])
|
||||||
|
'';
|
||||||
|
}
|
|
@ -77,7 +77,6 @@ mkIf config.m-0.laptop.enable {
|
||||||
evince
|
evince
|
||||||
gnome3.nautilus
|
gnome3.nautilus
|
||||||
|
|
||||||
(import (builtins.fetchGit "https://github.com/obsidiansystems/obelisk.git") {}).command
|
|
||||||
# (import (fetchTarball https://cachix.org/api/v1/install) {}).cachix
|
# (import (fetchTarball https://cachix.org/api/v1/install) {}).cachix
|
||||||
|
|
||||||
# look & feel
|
# look & feel
|
||||||
|
|
43
home-manager/on-foreign-machine.nix
Normal file
43
home-manager/on-foreign-machine.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) writeHaskellScript;
|
||||||
|
configPath = "/home/${config.home.username}/git/nixos/config";
|
||||||
|
gcRetentionDays = 5;
|
||||||
|
update-home-manager = (import ./lib.nix).update-home-manager configPath;
|
||||||
|
gcRetentionDays = 5;
|
||||||
|
user-maintenance = writeHaskellScript
|
||||||
|
{ name = "user-maintenance"; imports = [ ]; bins = [ update-home-manager pkgs.nix pkgs.git];} ''
|
||||||
|
main = do
|
||||||
|
git "-C" "${configPath}" "pull"
|
||||||
|
update_home_manager
|
||||||
|
nix_collect_garbage "--delete-older-than" "${toString gcRetentionDays}d"
|
||||||
|
nix "optimise-store"
|
||||||
|
'';
|
||||||
|
{
|
||||||
|
home =
|
||||||
|
sessionVariables = {
|
||||||
|
NIX_PATH = "$HOME/.nix-path";
|
||||||
|
};
|
||||||
|
file = {
|
||||||
|
home-manager-source = {
|
||||||
|
target = ".nix-path/home-manager";
|
||||||
|
source = sources.home-manager;
|
||||||
|
};
|
||||||
|
nixpkgsr-source = {
|
||||||
|
target = ".nix-path/nixpkgs";
|
||||||
|
source = sources.nixpkgs;
|
||||||
|
};
|
||||||
|
nixos = {
|
||||||
|
target = ".nix-path/nixos";
|
||||||
|
source = sources.nixpkgs;
|
||||||
|
};
|
||||||
|
unstable = {
|
||||||
|
target = ".nix-path/unstable";
|
||||||
|
source = sources.unstable;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
packages = builtins.attrValues {
|
||||||
|
inherit user-maintenance update-home-manager;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
21
home-manager/on-my-machine.nix
Normal file
21
home-manager/on-my-machine.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) writeHaskellScript getNivPath;
|
||||||
|
configPath = "/etc/nixos";
|
||||||
|
gcRetentionDays = 5;
|
||||||
|
update-home-manager = (import ./lib.nix).update-home-manager configPath;
|
||||||
|
system-maintenance = writeHaskellScript
|
||||||
|
{ name = "system-maintenance"; bins = [ pkgs.nix pkgs.git update-home-manager ];} ''
|
||||||
|
main = do
|
||||||
|
git "-C" "${configPath}" "pull"
|
||||||
|
exe "sudo" "update-system"
|
||||||
|
update_home_manager
|
||||||
|
exe "sudo" "nix-collect-garbage" "--delete-older-than" "${toString gcRetentionDays}d"
|
||||||
|
nix "optimise-store"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home.packages = builtins.attrValues {
|
||||||
|
inherit system-maintenance update-home-manager getNivPath;
|
||||||
|
};
|
||||||
|
}
|
80
home-manager/tests.nix
Normal file
80
home-manager/tests.nix
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) writeHaskellScript getNivPath home-manager unstable niv;
|
||||||
|
haskellBody = commandline:
|
||||||
|
''
|
||||||
|
|
||||||
|
data Host = Host {
|
||||||
|
configDir :: String,
|
||||||
|
hostname :: String
|
||||||
|
} deriving (Show, Data, Typeable)
|
||||||
|
|
||||||
|
host = Host{
|
||||||
|
configDir = def &= argPos 0,
|
||||||
|
hostname = def &= argPos 1
|
||||||
|
}
|
||||||
|
|
||||||
|
getNivPath dir = readTrim . get_niv_path ([i|#{dir :: String}/nix/sources.nix|] :: String)
|
||||||
|
|
||||||
|
getNivAssign dir name = fmap process . getNivPath dir $ name
|
||||||
|
where process str = ["-I", [i|#{name :: String}=#{str :: LBS.ByteString}|]]
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
host <- cmdArgs host
|
||||||
|
paths <- (concat <$>) . mapM (getNivAssign $ configDir host) $ ["nixpkgs", "unstable", "home-manager"]
|
||||||
|
${commandline}
|
||||||
|
'';
|
||||||
|
|
||||||
|
test-system-config = writeHaskellScript {
|
||||||
|
name = "test-system-config";
|
||||||
|
bins = [ getNivPath pkgs.nix ];
|
||||||
|
imports = ["System.Console.CmdArgs.Implicit"];
|
||||||
|
libraries = [ unstable.haskellPackages.cmdargs ];
|
||||||
|
} (haskellBody
|
||||||
|
''
|
||||||
|
nix $ ["build", "-f", "<nixpkgs/nixos>", "system"] ++ paths ++ ["-I", [i|nixos-config=#{configDir host}/hosts/#{hostname host}/configuration.nix|], "-o", [i|result-system-#{hostname host}|]]
|
||||||
|
'');
|
||||||
|
|
||||||
|
test-home-manager-config = writeHaskellScript {
|
||||||
|
name = "test-home-manager-config";
|
||||||
|
bins = [ getNivPath pkgs.nix ];
|
||||||
|
imports = ["System.Console.CmdArgs.Implicit"];
|
||||||
|
libraries = [ unstable.haskellPackages.cmdargs ];
|
||||||
|
} (haskellBody
|
||||||
|
''
|
||||||
|
nix $ ["build", "-f", "<home-manager/home-manager/home-manager.nix>"] ++ paths ++ ["--argstr", "confPath", [i|#{configDir host}/hosts/#{hostname host}/home.nix|], "--argstr", "confAttr", "", "--out-link", [i|result-home-manager-#{hostname host}|], "activationPackage"]
|
||||||
|
'');
|
||||||
|
|
||||||
|
repoSrc = "git@hera.m-0.eu:nixos-config";
|
||||||
|
bump-config = writeHaskellScript {
|
||||||
|
name = "bump-config";
|
||||||
|
bins = [ test-system-config test-home-manager-config pkgs.git pkgs.coreutils niv pkgs.git-crypt ];
|
||||||
|
imports = ["System.Console.CmdArgs.Implicit" "Control.Exception" "System.Directory (withCurrentDirectory)"];
|
||||||
|
libraries = [ unstable.haskellPackages.cmdargs ];
|
||||||
|
} ''
|
||||||
|
main = do
|
||||||
|
path <- readTrim pwd
|
||||||
|
bracket (do
|
||||||
|
dir <- (LT.unpack . LTE.decodeUtf8 <$>) . readTrim $ mktemp "-d"
|
||||||
|
git "clone" "${repoSrc}" dir
|
||||||
|
return dir)
|
||||||
|
(\dir -> rm "-rf" dir)
|
||||||
|
(\dir -> do
|
||||||
|
withCurrentDirectory dir $ (do
|
||||||
|
git_crypt "unlock"
|
||||||
|
niv "update")
|
||||||
|
mapM_ (test_system_config dir) ["apollo", "hera"]
|
||||||
|
mapM_ (test_home_manager_config dir) ["apollo", "hera", "hephaistos"]
|
||||||
|
git "-C" dir "commit" "-am" "Update dependencies with niv"
|
||||||
|
git "-C" dir "push"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home.packages = [
|
||||||
|
test-system-config
|
||||||
|
test-home-manager-config
|
||||||
|
bump-config
|
||||||
|
];
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ imports = [
|
||||||
"${(builtins.fetchGit "ssh://git@git.darmstadt.ccc.de/cdark.net/nixdark")}"
|
"${(builtins.fetchGit "ssh://git@git.darmstadt.ccc.de/cdark.net/nixdark")}"
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
../../system
|
../../system
|
||||||
../../system/modules/fonts.nix
|
../../system/fonts.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
../../home-manager
|
../../home-manager
|
||||||
|
../../home-manager/on-my-machine.nix
|
||||||
|
../../home-manager/tests.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
m-0 = {
|
m-0 = {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../home-manager
|
../../home-manager
|
||||||
|
../../home-manager/on-foreign-machine.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.systemctlPath = "/usr/bin/systemctl";
|
systemd.user.systemctlPath = "/usr/bin/systemctl";
|
||||||
|
@ -31,7 +32,6 @@ home = {
|
||||||
time = "C.UTF-8";
|
time = "C.UTF-8";
|
||||||
};
|
};
|
||||||
sessionVariables = {
|
sessionVariables = {
|
||||||
NIX_PATH = "nixpkgs=$HOME/git/nixos/nixpkgs:home-manager=$HOME/git/nixos/home-manager:$HOME/.nix-defexpr/channels";
|
|
||||||
LANGUAGE="en_US";
|
LANGUAGE="en_US";
|
||||||
LC_CTYPE="C.UTF-8";
|
LC_CTYPE="C.UTF-8";
|
||||||
LC_NUMERIC="C.UTF-8";
|
LC_NUMERIC="C.UTF-8";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
../../home-manager
|
../../home-manager
|
||||||
|
../../home-manager/on-my-machine.nix
|
||||||
./secret
|
./secret
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
"homepage": null,
|
"homepage": null,
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs-channels",
|
"repo": "nixpkgs-channels",
|
||||||
"rev": "55b8860aa209e987f6f15c523811e4861d97d6af",
|
"rev": "96151a48dd6662fb3f84bd16bbfe8a34f59d717a",
|
||||||
"sha256": "0ri58704vwv6gnyw33vjirgnvh2f1201vbflk0ydj5ff7vpyy7hf",
|
"sha256": "06cqc37yj23g3jbwvlf9704bl5dg8vrzqvs5y2q18ayg9sw61i6z",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/55b8860aa209e987f6f15c523811e4861d97d6af.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs-channels/archive/96151a48dd6662fb3f84bd16bbfe8a34f59d717a.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"unstable": {
|
"unstable": {
|
||||||
|
@ -41,10 +41,10 @@
|
||||||
"homepage": null,
|
"homepage": null,
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs-channels",
|
"repo": "nixpkgs-channels",
|
||||||
"rev": "362be9608c3e0dc5216e9d1d5f5c1a5643b7f7b1",
|
"rev": "c4fec1c6314c0c9c7af59bb465a17d1950ec7464",
|
||||||
"sha256": "0934rhanamsnhawg15gg6cy9ird3c47hsqn5s46lq2n5kzl6v7ly",
|
"sha256": "1w8wjvmsap0jn4gq2gg76yphsgvl6a9v5vsnkjr0jzda1q83zw4h",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/362be9608c3e0dc5216e9d1d5f5c1a5643b7f7b1.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs-channels/archive/c4fec1c6314c0c9c7af59bb465a17d1950ec7464.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (import ../common/my-lib.nix) writeHaskellScript getNivPath;
|
inherit (import ../common/lib.nix) home-manager;
|
||||||
me = config.m-0.private.me;
|
me = config.m-0.private.me;
|
||||||
sources = import ../nix/sources.nix;
|
sources = import ../nix/sources.nix;
|
||||||
nixpkgsPath = sources.nixpkgs;
|
|
||||||
unstablePath = sources.unstable;
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
../common
|
../common
|
||||||
|
./update-script.nix
|
||||||
./modules/laptop.nix
|
./modules/laptop.nix
|
||||||
./modules/git.nix
|
./modules/git.nix
|
||||||
./modules/mathechor.de.nix
|
./modules/mathechor.de.nix
|
||||||
|
@ -41,24 +40,13 @@ in {
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = [
|
systemPackages = [
|
||||||
(writeHaskellScript {
|
home-manager
|
||||||
name = "update-nixos";
|
|
||||||
imports = [ "qualified Data.ByteString.Lazy.Char8 as C" "qualified Data.List as L" ];
|
|
||||||
bins = [ getNivPath config.system.build.nixos-rebuild];
|
|
||||||
} ''
|
|
||||||
|
|
||||||
getNivAssign name = fmap process . readTrim $ get_niv_path "/etc/nixos/nix/sources.nix" name
|
|
||||||
where process str = ["-I", name ++ "=" ++ C.unpack str]
|
|
||||||
|
|
||||||
main = do
|
|
||||||
paths <- mapM getNivAssign ["nixpkgs", "unstable"]
|
|
||||||
nixos_rebuild (concat paths ++ ["switch"])
|
|
||||||
'')
|
|
||||||
];
|
];
|
||||||
etc = {
|
etc = {
|
||||||
"nix-path/nixpkgs".source = nixpkgsPath;
|
"nix-path/nixpkgs".source = sources.nixpkgs;
|
||||||
"nix-path/nixos".source = nixpkgsPath;
|
"nix-path/nixos".source = sources.nixpkgs;
|
||||||
"nix-path/unstable".source = unstablePath;
|
"nix-path/unstable".source = sources.unstable;
|
||||||
|
"nix-path/home-manager".source = sources.home-manager;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +58,6 @@ in {
|
||||||
"/etc/nix-path"
|
"/etc/nix-path"
|
||||||
"nixos-config=/etc/nixos/configuration.nix"
|
"nixos-config=/etc/nixos/configuration.nix"
|
||||||
];
|
];
|
||||||
gc.options = "--delete-older-than 5d";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|
29
system/update-script.nix
Normal file
29
system/update-script.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (import ../common/lib.nix) writeHaskellScript getNivPath getNivAssign home-manager;
|
||||||
|
configPath = "/etc/nixos";
|
||||||
|
update-system = writeHaskellScript {
|
||||||
|
name = "update-system";
|
||||||
|
imports = [ "qualified Data.ByteString.Lazy.Char8 as C" "qualified Data.List as L" ];
|
||||||
|
bins = [ getNivPath config.system.build.nixos-rebuild ];
|
||||||
|
}
|
||||||
|
''
|
||||||
|
getNivPath = fmap C.unpack . readTrim . get_niv_path "${configPath}/nix/sources.nix"
|
||||||
|
|
||||||
|
getNivAssign name = fmap process . getNivPath $ name
|
||||||
|
where process str = ["-I", name ++ "=" ++ str]
|
||||||
|
|
||||||
|
main = do
|
||||||
|
paths <- fmap concat . mapM getNivAssign $ ["nixpkgs", "unstable", "home-manager"]
|
||||||
|
nixos_rebuild (paths ++ ["switch"])
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
environment = {
|
||||||
|
systemPackages = [
|
||||||
|
update-system
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue