{"id":99772,"date":"2024-07-09T18:44:11","date_gmt":"2024-07-09T10:44:11","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=99772"},"modified":"2024-07-09T18:44:11","modified_gmt":"2024-07-09T10:44:11","slug":"function-linux-nixos","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/function-linux-nixos.html","title":{"rendered":"Linux \u53d1\u884c\u7248 NixOS \u53d1\u5e03 18.03 \u7248"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nNixOS \u662f\u4e00\u4e2a\u72ec\u7acb GNU\/Linux \u53d1\u884c\u7248\uff0c\u4ee5\u72ec\u7279\u7684\u65b9\u5f0f\u8fdb\u884c\u5305\u548c\u914d\u7f6e\u7ba1\u7406\u5e76\u56e0\u7531\u6b64\u5e26\u6765\u7684\u79cd\u79cd\u7279\u6027\u800c\u88ab\u79f0\u4e3a\u300c\u7eaf\u51fd\u6570\u5f0f\u300d\u3002\u5176\u57fa\u4e8e Nix \u5305\u7ba1\u7406\u5668\u6784\u5efa\uff0c\u91c7\u7528\u300c\u9648\u8ff0\u5f0f\u300d\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u63d0\u4f9b\u539f\u5b50\u6027\u7684\u66f4\u65b0\u53ca\u56de\u6eda\u673a\u5236\uff0c\u5bf9 DevOps \u53cb\u597d\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

4 \u6708 4 \u65e5\uff0cNixOS \u53d1\u5e03\u4e86\u4ee3\u53f7\u4e3a\u300cImpala\u300d\u7684 18.03 \u7248\u3002\u8fd9\u4e00\u7248\u672c\u5305\u542b\u5982\u4e0b\u663e\u8457\u53d8\u5316\uff1a<\/p>\n

1.\u652f\u6301 x86_64-linux \u53ca x86_64-darwin \u5e73\u53f0\uff08\u540e\u8005\u5176\u5b9e\u4e0d\u662f NixOS\uff09\uff1baarch64-linux \u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e5f\u5df2\u53ef\u7528\uff0c\u4f46\u56e0\u5176\u5c1a\u6709\u95ee\u9898\u5f85\u4fee\u590d\uff0c\u6545\u5176 channel\uff08\u53c2\u89c1 Hydra\uff09\u5c1a\u4e0d\u53ef\u7528\u3002<\/p>\n

2.Nix\uff08\u5305\u7ba1\u7406\u5668\uff09\u73b0\u5728\u9ed8\u8ba4\u4e3a 2.0 \u7248\u672c\u3002<\/p>\n

\u91cd\u8981\u7cfb\u7edf\u7ec4\u4ef6\u7248\u672c\u53d8\u5316<\/strong><\/span><\/div>\n

1.Linux: 4.9 \u81f3 4.14\uff1b
\n2.glibc: 2.25 \u81f3 2.26\uff1b
\n3.GCC: 6 \u81f3 7\uff1b
\n4.systemd: 234 \u81f3 237\u3002<\/p>\n

\u684c\u9762\u73af\u5883\u7248\u672c\u53d8\u5316<\/strong><\/span><\/div>\n

1.GNOME: 3.24 \u81f3 3.26\uff1b
\n2.KDE plasma: \u81ea 5.10 \u81f3 5.12\u3002
\n3.MariaDB \u81ea 10.1 \u5347\u7ea7\u81f3 10.2\uff0c\u4e14\u6210\u4e3a\u4e86\u9ed8\u8ba4\u7684 MySQL \u5b9e\u73b0\uff1b
\n4.PHP \u9ed8\u8ba4\u7248\u672c\u4ece 7.1 \u5347\u7ea7\u81f3 7.2\u3002<\/p>\n

\u6b64\u5916\uff0c\u6b64\u7248\u672c\u8fd8\u5305\u542b\u8bf8\u591a\u5176\u5b83\u53d8\u5316\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6b64\u7248\u672c\u5e26\u6765\u4e86\u4e00\u4e9b\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u8bf7\u5728\u5347\u7ea7\u65f6\u4ed4\u7ec6\u786e\u8ba4\u3002\u8be6\u7ec6\u4fe1\u606f\u89c1\u4e8e\u5176\u5176\u53d1\u5e03\u8bb0\u5f55\u3002<\/p>\n

\u6b64\u7248\u672c\u7684\u652f\u6301\u5c06\u4e8e 2018 \u5e74 10 \u6708\u672b\u505c\u6b62\uff0c\u800c\u540e 18.09 \u7248\u5c06\u53d6\u4ee3\u8fd9\u4e00\u7248\u672c\u3002<\/p>\n

\"\"<\/p>\n

NixOS \u8d77\u521d\u662f\u4e00\u4e2a\u7814\u7a76\u6027\u9879\u76ee\uff0c\u4f46\u73b0\u5728\u5176\u5df2\u662f\u4e00\u4e2a\u62e5\u6709\u5b8c\u5907\u529f\u80fd\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002NixOS \u65e8\u5728\u6539\u8fdb\u7cfb\u7edf\u914d\u7f6e\u7ba1\u7406\u7684\u65b9\u5f0f\u3002\u5728\u73b0\u6709\u7684\u53d1\u884c\u7248\u4e2d\uff0c\u5347\u7ea7\u7b49\u64cd\u4f5c\u662f\u5371\u9669\u7684\uff1a\u5bf9\u4e00\u4e2a\u8f6f\u4ef6\u5305\u8fdb\u884c\u5347\u7ea7\u53ef\u80fd\u4f7f\u5f97\u5176\u5b83\u8f6f\u4ef6\u5305\u51fa\u9519\uff0c\u5bf9\u6574\u4e2a\u7cfb\u7edf\u8fdb\u884c\u66f4\u65b0\u6bd4\u91cd\u88c5\u7cfb\u7edf\u66f4\u4e0d\u53ef\u9760\u3002\u7528\u6237\u65e0\u6cd5\u5b89\u5168\u5730\u6d4b\u8bd5\u5e76\u83b7\u77e5\u5bf9\u67d0\u4e00\u914d\u7f6e\u8fdb\u884c\u4fee\u6539\u5c06\u4f1a\u4ea7\u751f\u4f55\u79cd\u7ed3\u679c\uff0c\u56e0\u4e3a\u7528\u6237\u65e0\u6cd5\u5bf9\u8fd9\u4e00\u64cd\u4f5c\u8fdb\u884c\u53ef\u9760\u7684\u64a4\u9500\u3002\u56e0\u6b64\uff0c NixOS \u5e26\u7740\u6539\u53d8\u73b0\u72b6\u7684\u76ee\u6807\u51fa\u73b0\u4e86\u3002<\/p>\n

\u9648\u8ff0\u5f0f\uff08Declarative\uff09\u7684\u7cfb\u7edf\u914d\u7f6e\u6a21\u578b<\/strong><\/span><\/div>\n

NixOS \u7684\u7279\u6b8a\u4e4b\u5904\u5728\u4e8e\u5176\u9075\u5faa\u300c\u9648\u8ff0\u5f0f\uff08Declarative\uff09\u300d\u7cfb\u7edf\u914d\u7f6e\u6a21\u578b\u3002\u901a\u8fc7\u9884\u5148\u5199\u597d\u7684\u5bf9\u9884\u671f\u914d\u7f6e\u7684\u8bf4\u660e\uff0cNix \u5305\u7ba1\u7406\u5668\u53ef\u4ee5\u6784\u5efa\u6574\u4e2a\u64cd\u4f5c\u7cfb\u7edf\uff08\u5305\u542b\u5185\u6838\u3001\u5e94\u7528\u3001\u7cfb\u7edf\u5305\u53ca\u914d\u7f6e\u6587\u4ef6\u7b49\uff09\u3002\u8fd9\u4e00\u8bf4\u660e\u6027\u6587\u4ef6\u9075\u5faa\u7eaf\u51fd\u6570\u5f0f\u7684\u6784\u5efa\u8bed\u8a00\u2014\u2014\u6784\u5efa\u65b0\u7684\u914d\u7f6e\u4e0d\u4f1a\u8986\u76d6\u4e4b\u524d\u7684\u914d\u7f6e\u3002<\/p>\n

\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5728 \/etc\/nixos\/configuration.nix \u4e2d\u5199\u660e\u5176\u5e0c\u671b\u8bbe\u5907\u62e5\u6709\u7684\u9884\u671f\u529f\u80fd\uff08\u7ec4\u4ef6\uff09\u6765\u914d\u7f6e NixOS \u7cfb\u7edf\u3002\u4f8b\u5982\uff0c\u5982\u4e0b\u662f\u4e00\u4e2a\u6307\u660e\u4e86\u9700\u8981 SSH daemon \u670d\u52a1\u7684\u6700\u5c0f\u5316\u7cfb\u7edf\u914d\u7f6e\uff1a<\/p>\n

{\r\nboot.loader.grub.device = \"\/dev\/sda\";\r\n\r\nfileSystems.\"\/\".device = \"\/dev\/sda1\";\r\n\r\nservices.sshd.enable = true;\r\n}\r\n<\/pre>\n

\u5728\u66f4\u6539\u4e86\u4e0a\u8ff0\u6587\u4ef6\u4e4b\u540e\uff0c\u7528\u6237\u9700\u901a\u8fc7\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4f7f\u5176\u751f\u6548\uff1a<\/p>\n

$ nixos-rebuild switch\r\n<\/pre>\n

\u4e0a\u8ff0\u547d\u4ee4\u5c06\u8d1f\u8d23\u8fdb\u884c\u6240\u6709\u6240\u9700\u64cd\u4f5c\u4ee5\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u5176\u5305\u62ec\u4e0b\u8f7d\u5e76\u7f16\u8bd1 OpenSSH \u4ee5\u53ca\u4e3a SSH \u670d\u52a1\u5668\u751f\u6210\u914d\u7f6e\u6587\u4ef6\u7b49\u3002<\/p>\n

\u66f4\u65b0\u7684\u53ef\u9760\u6027<\/strong><\/span><\/div>\n

\u91c7\u7528\u7eaf\u51fd\u6570\u5f0f\u7684\u5305\u7ba1\u7406\u7b56\u7565\u7684\u53e6\u4e00\u4e2a\u4f18\u52bf\u662f\uff0cnixos-rebuild switch \u547d\u4ee4\u7684\u6267\u884c\u603b\u662f\u4ea7\u751f\u76f8\u540c\u7684\u7ed3\u679c\uff0c\u65e0\u8bba\u6b64\u524d\u7cfb\u7edf\u4e2d\u5305\u542b\u4e86\u54ea\u4e9b\u5305\u6216\u914d\u7f6e\u6587\u4ef6\u3002\u56e0\u6b64\uff0c\u8fd9\u907f\u514d\u4e86\u524d\u6587\u4e2d\u63d0\u5230\u7684\u95ee\u9898\uff0c\u4f7f\u5f97\u5347\u7ea7\u7cfb\u7edf\u548c\u91cd\u88c5\u7cfb\u7edf\u4e00\u6837\u53ef\u9760\u3002<\/p>\n

\u66f4\u65b0\u7684\u539f\u5b50\u6027<\/strong><\/span><\/div>\n

NixOS \u7684\u914d\u7f6e\u7ba1\u7406\u5177\u6709\u4e8b\u52a1\u6027\uff08Transactional\uff09\u7684\u7279\u70b9\uff1a\u5347\u7ea7\u7b49\u914d\u7f6e\u53d8\u5316\u662f\u539f\u5b50\u6027\u7684\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u66f4\u65b0\u5230\u4e00\u4e2a\u65b0\u914d\u7f6e\u7684\u8fc7\u7a0b\u88ab\u4e2d\u65ad\u4e86\uff08\u4f8b\u5982\uff0c\u4e2d\u9014\u65ad\u7535\uff09\uff0c\u7cfb\u7edf\u4ecd\u7136\u4f1a\u5904\u4e8e\u4e00\u81f4\u6027\u7684\u72b6\u6001\u3002\u5176\u53ea\u4f1a\u542f\u52a8\u81f3\u65e7\u7684\u6216\u65b0\u7684\u914d\u7f6e\uff0c\u800c\u4e0d\u4f1a\u5904\u4e8e\u5927\u591a\u5176\u5b83\u7cfb\u7edf\u4e2d\u53ef\u80fd\u51fa\u73b0\u7684\u4e0d\u4e00\u81f4\u72b6\u6001\uff08\u6b64\u79cd\u72b6\u6001\u5e38\u610f\u4ee3\u8868\u673a\u5668\u4e0d\u518d\u80fd\u6b63\u5e38\u542f\u52a8\uff09\u3002<\/p>\n

\u56de\u6eda<\/strong><\/span><\/div>\n

\u524d\u6587\u4e2d\u63d0\u5230\uff0cNix \u914d\u7f6e\u91c7\u7528\u7684\u7eaf\u51fd\u6570\u5f0f\u8bed\u8a00\u4f7f\u5f97\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u4e0d\u4f1a\u8986\u76d6\u65e7\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u7528\u6237\u53ef\u4ee5\u539f\u5b50\u6027\u5730\u56de\u6eda\u5230\u4e4b\u524d\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u6b21 nixos-rebuild switch \u4e4b\u540e\uff0c\u7528\u6237\u5bf9\u65b0\u7684\u914d\u7f6e\u4e0d\u6ee1\u610f\uff0c\u901a\u8fc7\u6267\u884c<\/p>\n

$ nixos-rebuild switch --rollback\r\n<\/pre>\n

\u5373\u53ef\u5b8c\u6210\u56de\u6eda\u3002<\/p>\n

\u800c\u4e14\uff0c\u6240\u6709\u65e7\u7684\u7cfb\u7edf\u914d\u7f6e\u4f1a\u81ea\u52a8\u51fa\u73b0\u5728 Grub \u542f\u52a8\u83dc\u5355\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u9009\u62e9\u83dc\u5355\u9879\u56de\u6eda\u5230\u5bf9\u5e94\u7684\u65e7\u914d\u7f6e\u6587\u4ef6\u3002\u8fd9\u4e00\u8fc7\u7a0b\u975e\u5e38\u4e4b\u5feb\u3002<\/p>\n

\u7531 NixOS \u53ca Nix \u7684\u72ec\u7279\u7684\u914d\u7f6e\u7ba1\u7406\u7b56\u7565\u5e26\u6765\u7684\u5176\u5b83\u7279\u6027\u4ee5\u53ca\u5bf9 NixOS\/Nix \u5de5\u4f5c\u539f\u7406\u7684\u7b80\u8981\u63cf\u8ff0\u89c1\u4e8e NixOS.org \u7684\u5173\u4e8e\u9875\u9762\u3002<\/p>\n

NixOS \u4e3b\u9875\uff1a
\nhttps:\/\/nixos.org\/<\/a><\/p>\n

\u4e0b\u8f7d\u5730\u5740\u53ca\u5b89\u88c5\u6307\u5f15\uff1a
\n
https:\/\/nixos.org\/nixos\/download.html<\/a><\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/openingsource.org\/1797\/<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/function-linux-nixos.html<\/a>\u7f16\u8f91\uff1a\u6768\u658c\u658c\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb NixOS \u662f\u4e00\u4e2a\u72ec\u7acb GNU\/Linux \u53d1\u884c\u7248\uff0c\u4ee5\u72ec\u7279\u7684\u65b9\u5f0f\u8fdb\u884c\u5305\u548c\u914d\u7f6e\u7ba1\u7406\u5e76\u56e0\u7531\u6b64\u5e26\u6765\u7684\u79cd\u79cd\u7279\u6027\u800c […]<\/p>\n","protected":false},"author":1476,"featured_media":99774,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-99772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/99772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1476"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=99772"}],"version-history":[{"count":12,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/99772\/revisions"}],"predecessor-version":[{"id":99915,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/99772\/revisions\/99915"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/99774"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=99772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=99772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=99772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}